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