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