n = int(input()) A = list(map(int, input().split())) if 0 in A: print(0) exit() ans = 1 for a in A: ans *= a ans %= 9 if ans == 0: ans = 9 print(ans)