p=1000000007 N,*A=map(int, open(0).read().split()) l,a,b,c=0,1,1,1 for r in range(N): a*=A[r] b*=pow(A[r],r-l+1,p) b%=p while a>=p-7: b*=pow(a,p-2,p) a//=A[l] l+=1 c*=b c%=p print(c)