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