n = int(input()) p = list(map(lambda x: int(x)%9,input().split())) ans = 1 for a in p: ans *= p ans %= 9 print(ans)