N = int(input()) P = list(map(int,input().ssplit())) ans = 1 for p in P: ans = ans * p % 9 print(ans)