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