#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector P(N); rep(i,N) cin >> P[i]; int ZERO = 0; rep(i,N) ZERO |= P[i] == 0; if(ZERO) { cout << 0 << endl; } else { ll ans = 1; rep(i,N) ans = (ans * (P[i] % 9)) % 9; cout << (ans == 0 ? 9 : ans) << endl; } }