n=int(input()) t=map(int,input().split()) x=1 for i in t: x*=i x%=9 if x==0: print(9) else: print(x)