#include #include #include #include #include #include #include #include #include #include #define rep(i,n)for(int i=0;iP; void pyes() { cout << "Yay!" << endl; } void pno() { cout << ":(" << endl; } int gcd(int x, int y) { if (y == 0)return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } //繰り返し二乗法 int mod_pow(int x, int y, int m) { int res = 1; while (y) { if (y & 1) { res = res * x % m; } x = x * x % m; y >>= 1; } return res; } //xCy int comb(int x, int y) { if (y > x)return 0; return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod; } int f(int x) { int ans = 1; for (int i = 1; i <= x; i++) { ans *= i; ans %= mod; } return ans; } struct edge { int to, cost; }; int n; int a[114514]; signed main() { cin >> n; rep(i, n)cin >> a[i]; int ans = 1; rep(i, n) { ans *= a[i]; if (ans % 9 != 0)ans %= 9; } if (n == 0)cout << 0 << endl; else if (ans % 9 == 0)cout << 9 << endl; else cout << ans % 9 << endl; ggr }