#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 = P[0] % 9; for (int i = 1; i < N; i++) { if (k == 0) { cout << "9\n"; return 0; } k *= P[i]; k %= 9; } cout << k << "\n"; return 0; }