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