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