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