#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) #define fi first #define se second template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = 0; //---------------------------------// int main() { int N; cin >> N; vector P(N); REP(i, N) scanf("%lld", &P[i]); REP(i, N) if (P[i] == 0) { puts("0"); return 0; } ll ans = 1; REP(i, N) { ans *= P[i] % 9; ans %= 9; } if (ans == 0) ans = 9; cout << ans << endl; return 0; }