#include using namespace std; using ll = long long; using ull = unsigned long long; using V = vector; using VV = vector; using VVV = vector; using VL = vector; using VVL = vector; using VVVL = vector; template using VE = vector; template using P = pair; #define rep(i,n) for(int i=0;i<(n);i++) #define rep1(i,n) for(int i=1;i<=(n);i++) #define REP(i,k,n) for(int i=(k);i<(n);i++) #define all(a) (a).begin(),(a).end() #define output(x,y) cout << fixed << setprecision(y) << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } const ll MOD = 1e9 + 7; // const ll MOD = 998244353; ll upper = MOD + MOD; ll under = -upper; ll UPPER = MOD * MOD; ll UNDER = -UPPER; const long double pi = 3.141592653589793; ll f(ll x) { ll res = 0; while (x) { res += x % 10; x /= 10; } return res; } int main() { // 無証明、恥ずかしくないの? int n; cin >> n; ll ans = 1; rep(i, n) { ll x; cin >> x; ans *= f(x); while (ans >= 10) ans = f(ans); } cout << ans << endl; return 0; }