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] mul_all = left_mul[N] ans = 1 MOD = 1000000007 arr = [0] * 100010 val = [0] * 100010 for i in range(N): lv = 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)