N = int(input()) A = list(map(int, input().split())) # left_mul = [0] * 100010 # right_mul = [0] * 100010 # left_mul[0] = 1 # for i in range(N): # left_mul[i+1] = left_mul[i] * A[i] # right_mul[0] = 1 # for i in range(N): # right_mul[i+1] = right_mul[i] * A[N-1-i] l1 = 0 r1 = 1 cur = A[0] ps = [0] * 100010 for i in range(N): ps[i] = N-1 while l1 < N: if r1 == N: ps[l1] = r1-1 break if cur * A[r1] >= 1000000000: ps[l1] = r1-1 cur //= A[l1] l1 += 1 else: cur *= A[r1] r1 += 1 ans = 1 MOD = 1000000007 arr = [0] * 100010 val = [0] * 100010 for i in range(N): lv = ps[i] # rv = N # while rv - lv > 1: # mid = (rv + lv) // 2 # mul_v = mul_all // left_mul[i] // right_mul[N-1-mid] # if mul_v >= 1000000000: # rv = mid # else: # lv = mid length = lv - i + 1 val[i] += length arr[lv+2] += 1 # for j in range(i,lv+1): # ans *= pow(A[j], length,MOD) # ans %= MOD # length -= 1 for i in range(N+1): arr[i+1] += arr[i] n = 0 cur = 0 # print(val[:10]) # print(arr[:10]) for i in range(N): cur += val[i] cur -= n; cur += arr[i] # print(cur) ans *= pow(A[i], cur, MOD) ans %= MOD n += 1 print(ans)