#include "bits/stdc++.h" #define rep(i,n) for(int i=0;i> N; ll ans = 1, P; rep(i, N) { cin >> P; if (P == 0) { cout << 0 << endl; return 0; } ans = (ans * (P % 9)) % 9; } cout << (ans + 8) % 9 + 1 << endl; }