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