#include #include #include #define int long long using namespace std; int sumdig(int N) { int dig, sum = 0; while (N) { dig = N % 10; sum += dig; N /= 10; } return sum; } signed main() { int N; cin >> N; int P; int sum = 1; for (int i = 0; i < N; i++) { cin >> P; sum *= P; } int ans = 0; while (1) { ans = sumdig(sum); sum = ans; if (ans <= 9) { cout << ans << endl; return 0; } } }