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