#yuki933 n=int(raw_input()) p=map(int,raw_input().split()) res=1 f=True for i in p: res*=i res%=9 if not i: f=False if f: if res==0: print 9 else: print res else: print 0