n=int(input()) a=list(map(int,input().split())) ans=1 mod=10**9+7 for i in range(n): ans*=pow(a[i],(i+1)*(n-i),mod) ans%=mod print(ans)