#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main() { int N; cin >> N; LL K = 1; rep(i, N) { LL A; cin >> A; if (A == 0) { cout << 0 << endl; return 0; } K = K * (A % 9) % 9; } if (K == 0) K = 9; cout << K << endl; return 0; }