#include using namespace std; #define rep(i,x,y) for(int i=x;i>N; long res=1;long a; rep(i,0,N){ cin>>a; (res*=a)%=9; } cout<<(res==0 ? 9 : res)<