#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, n) for (int i = 1; i <= (int)(n); i++) #define ll long long #define umap unordered_map using graph = vector>; using graph2 = vector>>; #define oorret true //std::out_of_rangeが返された時 #define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}() double pi = 3.141592653589793238; ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up ll M=1e9+7; ll L=1e9; int quick_pow(ll x,ll p){ int a=1,po=x; while(p){ if(p&1) a=1ll*a*po%M; po=1ll*po*po%M;p>>=1; } return a; } int main(){ int N; cin>>N; vector A(N); rep(i, N){ cin>>A[i]; } sort(A.begin(), A.end()); if(A[0]==0){ cout<<0<=L){ for(int j=i;j<=b;j++){ B[j]+=b-j+1; } continue; }else{ b=min(b+1, N-1); } } int j; if(i==0){ b=0; } for(j=b+1;j=L){ b=j-1; break; } } if(j==N){ b=N-1; } for(j=i;j<=b;j++){ B[j]+=b-j+1; } } ll ans=1; rep(i, N){ ans*=quick_pow(A[i], B[i]); ans%=M; } cout<