N=int(input()) P=list(map(int,input().split())) temp=1 for p in P: if p%9==0: print(9) exit() else: temp=(temp*p)%9 print(temp)