#include using namespace std; int N; int F=0; long T=1; main() { cin>>N; for(int i=0;i>A; if(!F&&(A>=9||T>=9||A*T>=9))F=1; T=A%9*T%9; } cout<<(T?T:F?9:0)<