/*
ID: jhqwan1
PROG: crypt1
LANG: C++11
*/
#include <fstream>
#include <iostream>
using namespace std;
int n, s[10], a, b, c, d, e, ans = 0;
ifstream fin("crypt1.in");
ofstream fout("crypt1.out");
#define cin fin
#define cout fout
bool yes;
inline void bao();
main()
{
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> s[i];
bao();
cout << ans;
// for(;;);
}
inline void bao(){
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
for (int k = 1; k <= n; ++k){
a = s[i] * 100 + s[j] * 10 + s[k];
for (int l = 1; l <= n; ++l)
for (int m = 1; m <= n; ++m){
yes = 1;
b = s[l] * 10 + s[m];
c = a * (b % 10);
if (c < 100 || c > 999)
continue;
while (c > 0){
d = c % 10;
c /= 10;
int o;
for (o = 1; o <= n; ++o)
if (d == s[o])
break;
if (o > n){
yes = 0;
break;
}
}
if (! yes)
continue;
d = a * (b / 10);
if (d < 100 || d > 999)
continue;
while (d > 0){
e = d % 10;
d /= 10;
int o;
for (o = 1; o <= n; ++o)
if (e == s[o])
break;
if (o > n){
yes = 0;
break;
}
}
if (! yes)
continue;
e = a * b;
if (e < 1000 || e > 9999)
continue;
while (e > 0){
c = e % 10;
e /= 10;
int o;
for (o = 1; o <= n; ++o)
if (c == s[o])
break;
if (o > n){
yes = 0;
break;
}
}
if (! yes)
continue;
ans++;
}
}
}