N = int(input()) A = list(map(int, input().split())) B = [0] * N B[0] = A[0] for i in range(1, N): B[i] = pow(A[i], i + 1, 1000000007) B[i] *= B[i - 1] B[i] %= 1000000007 print(B) j = 0 t = 1 a = [] for i in range(N): t *= A[i] while t > 1000000007: t //= A[j] j += 1 if j == 0: a.append(B[i]) else: a.append(B[i] * pow(B[j - 1], 1000000007 - 2, 1000000007)) print(a) result = 1 for i in range(len(a)): result *= a[i] result %= 1000000007 print(result)