#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; unsigned long long mul = 1; for (size_t i = 0; i < N; ++i) { unsigned long long p; cin >> p; mul *= p; } while (true) { if (to_string(mul).length() == 1) { return cout << mul << "\n", 0; } else { unsigned long long sum = 0; while (mul > 0) { sum += mul % 10; mul /= 10; } mul = sum; } } return 0; }