import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) p = list(map(int, readline().split())) k = 1 for pp in p: if pp == 0: print(0) exit() k *= (pp % 9) k %= 9 print(9 if k == 0 else k)