#include using namespace std; typedef long long ll; int main() { int N; cin >> N; ll P[N]; for (int i = 0; i < N; i++) { cin >> P[i]; } ll k = 1; for (int i = 0; i < N; i++) { if (P[i] % 9 == 0) { k = 9; } else if (P[i] == 0) { cout << "0\n"; return 0; } k *= (P[i] % 9); k %= 9; } if (k == 0) { cout << "9\n"; return 0; } cout << k << "\n"; return 0; }