/*
ID: awsd1231
PROG: crypt1
LANG: C++
*/
#include<iostream>
#include<cstdio>
using namespace std;
int n, num[10] = {0}, equa[60000][5];
int main() {
freopen("crypt1.in", "r", stdin);
freopen("crypt1.out", "w", stdout);
cin >> n;
for(int i = 0; i != n; ++i) {
cin >> num[i];
}
int idx = 0;
for(int a = 0; a != n; ++a) {
for(int b = 0; b != n; ++b) {
for(int c = 0; c != n; ++c) {
for(int d = 0; d != n; ++d) {
for(int f = 0; f != n; ++f) {
equa[idx][0] = num[a];
equa[idx][1] = num[b];
equa[idx][2] = num[c];
equa[idx][3] = num[d];
equa[idx++][4] = num[f];
} } } } }
int count = 0;
for(int i = 0; i != idx; ++i) {
int a = equa[i][0]*100 + equa[i][1]*10 + equa[i][2];
int b = equa[i][3] * 10 + equa[i][4];
int w1 = a*b%10, w2 = a*b/10%10, w3 = a*b/100%10, w4 = a*b/1000%10;
int l1 = a*equa[i][4]%10, l2 = a*equa[i][4]/10%10, l3 = a*equa[i][4]/100%10, l4 = a*equa[i][4]/1000;
int t1 = a*equa[i][3]%10, t2 = a*equa[i][3]/10%10, t3 = a*equa[i][3]/100%10, t4 = a*equa[i][3]/1000;
bool can[14] = {0};
if(a*b > 9999 || a*equa[i][4] > 999) continue;
for(int j = 0; j != n; j++) {
if(!can[0] && (w1 == num[j])) can[0] = true;
if(!can[1] && (w2 == num[j])) can[1] = true;
if(!can[2] && (w3 == num[j])) can[2] = true;
if(!can[3] && (w4 == num[j])) can[3] = true;
can[4] = true;
if(!can[5] && (l1 == num[j])) can[5] = true;
if(!can[6] && (l2 == num[j])) can[6] = true;
if(!can[7] && (l3 == num[j])) can[7] = true;
if(!can[8] && (l4 == num[j] || l4 == 0)) can[8] = true;
if(!can[9] && (t1 == num[j])) can[9] = true;
if(!can[10] && (t2 == num[j])) can[10] = true;
if(!can[11] && (t3 == num[j])) can[11] = true;
if(!can[12] && (t4 == num[j] || t4 == 0)) can[12] = true;
}
can[13] = true;
for(int i = 0; i != 13; ++i)
if(!can[i]) can[13] = false;
if(can[13]) count++;
}
cout << count << endl;
return 0;
}