#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef pair P; typedef long long ll; ll culc(ll a){ while(a>=10){ ll tmp = 0; string s = to_string(a); for(auto i:s){ tmp+=(i-'0'); } a = tmp; } return a; } int main(){ int n; cin >> n; ll res = 1; rep(i,n){ ll p; cin >> p; res = culc(res*p); } cout << res << endl; return 0; }