#include using namespace std; using ll = long long; #define rep(i,a,b) for(int i=int(a);i=m)x-=m; return *this;} mint &operator-=(mint b){if((x-=b.x)<0)x+=m; return *this;} mint &operator*=(mint b){x=ll(x)*b.x%m; return *this;} mint pow(ll e) const { mint r = 1,b =*this; while(e){ if(e&1) r*=b; b*=b; e>>=1; } return r; } mint inv(){return pow(m-2);} mint &operator/=(mint b){return *this*=b.pow(m-2);} friend mint operator+(mint a,mint b){return a+=b;} friend mint operator-(mint a,mint b){return a-=b;} friend mint operator/(mint a,mint b){return a/=b;} friend mint operator*(mint a,mint b){return a*=b;} }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector A(N); rep(i,0,N) cin>>A[i]; int L=(1<<20); vector fact(L,1),fact_inv(L,1); rep(i,1,L) fact[i]=fact[i-1]*i; fact_inv[L-1]=fact[L-1].inv(); for(int i=L-1;i>0;i--) fact_inv[i-1]=fact_inv[i]*i; auto comb=[&](ll a,ll b) -> mint { if(a<0||a