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