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