#include #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ll long long #define INF 1000000000000000000 int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector A(N); rep(i, N) { cin >> A[i]; } ll MOD = pow(10, 9); ll a = 1, b = 0; rep(i, N) { a *= A[i]; if (a >= MOD) b += a / MOD; a %= MOD; } ll ans = 0; string first; string aa = to_string(a), bb = to_string(b); first = bb + aa; while (1) { rep(i, first.size()) { ans += first[i] - '0'; } if (ans < 10) { cout << ans << endl; return 0; } first = to_string(ans); ans = 0; } return 0; }