N = int(input()) P = list(map(int, input().split())) if not all(P): print(0) else: K = 1 for i in range(N): K *= P[i] % 9 K %= 9 print(K if K != 0 else 9)