#include using namespace std; typedef long long ll; int main(){ int n; cin >> n; ll p = 1; for(int i = 0; i < n; i++){ ll x; cin >> x; p = p*x%9==0 ? 9 : p*x%9; } cout << p << endl; return 0; }