#include using namespace std; typedef long long ll; int main() { int n; cin >> n; vector p(n); for (int i = 0; i < n; i++) { cin >> p[i]; } ll ans = 1; bool flg = true; for (int i = 0; i < n; i++) { if (p[i] == 0) { flg = false; } ans = (ans * (p[i] % 9)) % 9; } if (flg && ans == 0) { ans = 9; } cout << ans << endl; return 0; }