#include #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define repi(i,a,b) for(int (i)=(a);(i)<(b);(i)++) typedef long long ll; using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; ll p[n]; ll k = 1; rep(i,n){ cin >> p[i]; k *= p[i]; } ll dig; ll sum = 0; goto keisan; keisan: while(k){ dig = k % 10; sum = sum + dig; k = k / 10; } int a = to_string(sum).length(); if(a!=1){ k = sum; sum = 0; goto keisan; }else{ cout << sum << endl; return 0; } }