#include using namespace std; using ll = long long; int main() { int n;cin >>n; vector p(n); ll mult =1; for(int i=0;i> p[i]; mult*=p[i]; } if(mult%9==0){ cout << 9 << endl; }else{ cout << mult%9 << endl; } return 0; }