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