#include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define FOR(init,num,inc) for(int i=init; i<num;i=i+inc)
#define N "\n"
#define VII vector<int> :: iterator
#define VILLI vector<long long int> :: iterator
#define my_input(n) for(int i=0,a;i<n;i++) {cin>>a; v.PB(a);}
#define sz size()
#define fst first
#define snd second
#define FV 100005
#define SX 1000005
#define scint(a) scanf("%d", &a)
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
typedef int I;
typedef long long int llint;
typedef vector<int> VI;
typedef vector<long long int > VLLI;
typedef vector<string> VS;
typedef set<int> SI;
typedef set<long long int> SLLI;
typedef set<string> SS;
int aar[1003], ar[10030], dp[10030];
void prime(int n )
{
int flag=0;
if(n==1) return ;
for(int i=2; i<=sqrt(n); i++)
{
if(n%i==0) {ar[i]++; flag=1; n=n/i; break;}
}
if(flag!=0)
prime(n);
else
{
ar[n]++;
}
}
int main()
{
llint ans=0, d=0, d2=0;
for(int i=0; i< 10 ; i++)
{
cin>>aar[i];
}
for(int i=0; i<10; i++)
{
prime(aar[i]);
}
for(int i=2; i<=10000;i++)
{
if(ar[i]>0)
{
d++;
d2+=ar[i];
dp[ar[i]]++;
}
}
for(int i=10000; i>=1; i--)
{
dp[i]=dp[i]+dp[i+1];
}
if(d==0) {cout<<1; return 0;}
ans+=d; ans+=2;
for(int i=d2-1;i>=2; i-- )
{
int x=d2-i+1;
ans+=dp[x];
for(int j=x-1; j>x/2; j--)
{
ans+=(llint)dp[j]*(dp[x-j]-1);
}
if(x%2==0)
{
ans+=(((llint)dp[x/2]-1)*dp[x/2])/2;
}
}
cout<<ans%10;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIE1QIG1ha2VfcGFpcgojZGVmaW5lIFBCIHB1c2hfYmFjawojZGVmaW5lIEZPUihpbml0LG51bSxpbmMpIGZvcihpbnQgaT1pbml0OyBpPG51bTtpPWkraW5jKQojZ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GVsc2UKICAgIHsKICAgICAgICBhcltuXSsrOwogICAgfQp9CgppbnQgbWFpbigpCnsKCiAgICBsbGludCBhbnM9MCwgZD0wLCBkMj0wOwogICAgZm9yKGludCBpPTA7IGk8IDEwIDsgaSsrKQogICAgewogICAgICAgIGNpbj4+YWFyW2ldOwogICAgfQogICAgZm9yKGludCBpPTA7IGk8MTA7IGkrKykKICAgIHsKICAgICAgICBwcmltZShhYXJbaV0pOwogICAgfQogICAgZm9yKGludCBpPTI7IGk8PTEwMDAwO2krKykKICAgIHsKICAgICAgICBpZihhcltpXT4wKQogICAgICAgIHsKICAgICAgICAgICAgZCsrOwogICAgICAgICAgICBkMis9YXJbaV07CiAgICAgICAgICAgIGRwW2FyW2ldXSsrOwogICAgICAgIH0KICAgIH0KCgogICAgZm9yKGludCBpPTEwMDAwOyBpPj0xOyBpLS0pCiAgICB7CiAgICAgICAgZHBbaV09ZHBbaV0rZHBbaSsxXTsKICAgIH0KICAgIGlmKGQ9PTApIHtjb3V0PDwxOyByZXR1cm4gMDt9CiAgICBhbnMrPWQ7IGFucys9MjsKCgogICAgZm9yKGludCBpPWQyLTE7aT49MjsgaS0tICkKICAgIHsKICAgICAgICBpbnQgeD1kMi1pKzE7CiAgICAgICAgYW5zKz1kcFt4XTsKICAgICAgICBmb3IoaW50IGo9eC0xOyBqPngvMjsgai0tKQogICAgICAgIHsKICAgICAgICAgICAgYW5zKz0obGxpbnQpZHBbal0qKGRwW3gtal0tMSk7CiAgICAgICAgfQogICAgICAgIGlmKHglMj09MCkKICAgICAgICB7CiAgICAgICAgICAgIGFucys9KCgobGxpbnQpZHBbeC8yXS0xKSpkcFt4LzJdKS8yOwogICAgICAgIH0KCgogICAgfQogICAgY291dDw8YW5zJTEwOwoKfQo=