N = int(input()) P = list(map(int, input().split())) if 0 in P: print(0) else: ans = 1 for x in P: ans *= x ans %= 9 print((ans - 1) % 9 + 1)