#include using namespace std; int main() { ios::sync_with_stdio(false); int N; cin >> N; vector P(N); for (int i = 0; i < N; ++i) { cin >> P[i]; } bool zero = false; int ans = 1; for (int64_t p : P) { zero |= p == 0; ans = ans * (p % 9) % 9; } if (zero) cout << 0 << endl; else if (ans == 0) cout << 9 << endl; else cout << ans << endl; return 0; }