N = int(input()) A = list(map(int,input().split())) import sys for a in A: if a == 0: print(0) exit() P = 10 ** 9 + 7 ans = 1 souseki = 1 seki = 1 right = 0 for left in range(N): while right < N and seki * A[right] < 10 ** 9: seki *= A[right] souseki = souseki * seki % P right += 1 ans = ans * souseki % P inv = pow(A[left],P-2,P) seki = seki // A[left] delta = right - left souseki = souseki * pow(inv,right-left,P) print(ans)