枚举没什么好说的
/*
ID: Jang Lawrence
PROG: crypt1
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int p[5];
int b,c,d,e,f;
int ans=0;
bool in[10];
bool is()
{
int x=b*100+c*10+d,y=e*10+f;
if(e*x>=1000) return 0;
if(f*x>=1000) return 0;
int t=e*x;
while(t)
{
if(!in[t%10]) return 0;
t/=10;
}
t=f*x;
while(t)
{
if(!in[t%10]) return 0;
t/=10;
}
t=y*x;
while(t)
{
if(!in[t%10]) return 0;
t/=10;
}
return 1;
}
int main()
{
#ifndef DEBUG
freopen("crypt1.in","r",stdin);
freopen("crypt1.out","w",stdout);
#endif
int n;
int a[11];
scanf("%d",&n);
for(int i=1;i<=n;++i)
{scanf("%d",a+i); in[a[i]]=1;}
for(int i=1;i<=n;++i){
b=a[i];
for(int j=1;j<=n;++j)
{
c=a[j];
for(int k=1;k<=n;++k)
{
d=a[k];
for(int s=1;s<=n;++s)
{
e=a[s];
for(int ii=1;ii<=n;++ii)
{f=a[ii];
if(is()) ans++;
}
}
}
}
}
printf("%d\n",ans);
return 0;
}