// yuki 933 おまわりさんこいつです // 2019.11.30 bal4u #include #include #include int getchar_unlocked(void); #define gc() getchar_unlocked() int in() { // 非負整数の入力 int n = 0; int c; do c = gc(); while (isspace(c)); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } void ins(char *s) { int c; while (isspace(c = gc())); do *s++ = c; while ((c = gc()) >= '0'); *s = 0; } int s2c(char *s) { int a = 0; while (*s) a += *s++ & 0xf; return a; } int i2c(int n) { int a = 0; while (n) a += n % 10, n /= 10; return a; } int main() { int i, N, t, ans; char P[30]; ans = 1; N = in(); while (N--) { ins(P); t = s2c(P); if (t == 0) { puts("0"); return 0; } ans = i2c(ans * t); } while (ans >= 10) ans = i2c(ans); putchar(ans+'0'), putchar('\n'); return 0; }