#include "bits/stdc++.h" #pragma GCC optimize("Ofast") // Begin {{{ using namespace std; #ifndef DEBUG #define dump(...) #endif template inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); } template inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); } template inline vector make_v(const T &initvalue, size_t sz) { return vector(sz, initvalue); } template inline auto make_v(const T &initvalue, size_t sz, Args... args) { return vector(initvalue, args...))>(sz, make_v(initvalue, args...)); } constexpr int INF = 0x3f3f3f3f; constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL; // }}} End signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); size_t N; cin >> N; intmax_t res = 1; for (size_t i = 0; i < N; ++i) { intmax_t p; cin >> p; if (p == 0) { return cout << 0 << "\n", 0; } else { if (p % 9 == 0) { res *= 9; } else { (res *= p) %= 9; } } } cout << res << "\n"; return 0; }