def digit(n): if n==0: return 0 q=str(n) tmp=0 for i in range(len(q)): tmp+=int(q[i]) if tmp%9!=0: tmp%=9 else: tmp=9 return tmp n=int(input()) p=list(map(int,input().split())) ct=1 for i in range(n): ct*=p[i] ans=digit(ct) print(ans)