P13196 [CodeChef] proposal
提高-
题目描述

In PrimeLand, there existed a very handsome young prince named Prima. He greatly desired the Princess of Mathematics – Facie. However, before accepting his hand in marriage, Facie asked Prima to solve the following problem:

The figure below shows a simple multiplication problem. However, not all the decimal digits are available. Prima has to find an assignment of digits to the marked places so that the multiplication is valid.

  * * *

x * *
-------
* * * <-- partial product 1
* * * <-- partial product 2
-------
* * * *

Digits can appear only in places marked by `*'. Of course, leading zeroes are not allowed.
Write a program to help Prima that will find all solutions to this problem for any subset of digits from the set {1,2,3,4,5,6,7,8,9}.

Input
The first line contains N, the number of digits that will be used
The second line contains N space separated digits

Output
A single line with the total number of unique solutions. Here is the single solution for the sample input:

  2 2 2
x   2 2
 ------
  4 4 4
4 4 4

4 8 8 4

Example

Input:
5
2 3 4 6 8

Output:
1

输入格式

见题面

输出格式

见题面

样例输入
5 2 3 4 6 8
样例输出
1