#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int f(long long x) { return x % 9 == 0 ? 9 : x % 9; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int ret = 1; int zero = 0; REP (i, n) { long long p; cin >> p; if (!p) ++zero; ret = f(f(p) * ret); } if (zero) ret = 0; cout << ret << endl; return 0; }