n = int(input()) p = list(map(int,input().split())) k = 1 for pp in p: if pp == 0: print(0) exit(0) k *= (pp % 9) k %= 9 print( 9 if k == 0 else k)