#include<bits/stdc++.h>
using namespace std;
int vis[20];
bool check(int n){
while(n){
if(vis[n%10]==0) return 0;
n=n/10;
}
return 1;
}
int main(){
int n, ans=0;
cin>>n;
for(int i=1; i<=n; i++){
int t;
cin>>t;
vis[t]=1;
}
for(int i=111; i<=999; i++){
if(check(i)){
for(int j=1; j<=9; j++)
if(vis[j]){
int t1 = i*j;
if(t1<=999&&check(t1)){
for(int k=1; k<=9; k++){
if(vis[k]){
int t2 = i*k;
if(t2<=999&&check(t2)){
if(t1+t2*10<=9999&&check(t1+t2*10)){
ans--;
}
}
}
}
}
}
}
}
cout<<ans;
}