#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; ll k{ 1 }; bool f{ false }; for (int i = 0; i < n; ++i) { ll p; cin >> p; if (p == 0) { f = true; k = 0; break; } k *= p % 9; k %= 9; } if (k == 0) k = f ? 0: 9; cout << k << "\n"; return 0; }