#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; template struct mint{ static constexpr T mod = MOD; T v; mint():v(0){} mint(signed v):v(v){} mint(long long t){v=t%MOD;if(v<0) v+=MOD;} mint pow(long long k){ mint res(1),tmp(v); while(k){ if(k&1) res*=tmp; tmp*=tmp; k>>=1; } return res; } static mint add_identity(){return mint(0);} static mint mul_identity(){return mint(1);} mint inv(){return pow(MOD-2);} mint& operator+=(mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;} mint& operator-=(mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;} mint& operator*=(mint a){v=1LL*v*a.v%MOD;return *this;} mint& operator/=(mint a){return (*this)*=a.inv();} mint operator+(mint a) const{return mint(v)+=a;}; mint operator-(mint a) const{return mint(v)-=a;}; mint operator*(mint a) const{return mint(v)*=a;}; mint operator/(mint a) const{return mint(v)/=a;}; mint operator-() const{return v?mint(MOD-v):mint(v);} bool operator==(const mint a)const{return v==a.v;} bool operator!=(const mint a)const{return v!=a.v;} bool operator <(const mint a)const{return v constexpr T mint::mod; template ostream& operator<<(ostream &os,mint m){os< struct NTT{ static constexpr int md = bmds(X); static constexpr int rt = brts(X); using M = mint; vector< vector > rts,rrts; void ensure_base(int n){ if((int)rts.size()>=n) return; rts.resize(n);rrts.resize(n); for(int i=1;i &as,bool f,int n=-1){ if(n==-1) n=as.size(); assert((n&(n-1))==0); ensure_base(n); for(int i=0,j=1;j+1>1;k>(i^=k);k>>=1); if(i>j) swap(as[i],as[j]); } for(int i=1;i multiply(vector as,vector bs){ int need=as.size()+bs.size()-1; int sz=1; while(sz multiply(vector as,vector bs){ vector am(as.size()),bm(bs.size()); for(int i=0;i<(int)am.size();i++) am[i]=M(as[i]); for(int i=0;i<(int)bm.size();i++) bm[i]=M(bs[i]); vector cm=multiply(am,bm); vector cs(cm.size()); for(int i=0;i<(int)cs.size();i++) cs[i]=cm[i].v; return cs; } }; template constexpr int NTT::md; template constexpr int NTT::rt; namespace FFT{ using dbl = double; struct num{ dbl x,y; num(){x=y=0;} num(dbl x,dbl y):x(x),y(y){} }; inline num operator+(num a,num b){ return num(a.x+b.x,a.y+b.y); } inline num operator-(num a,num b){ return num(a.x-b.x,a.y-b.y); } inline num operator*(num a,num b){ return num(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x); } inline num conj(num a){ return num(a.x,-a.y); } int base=1; vector rts={{0,0},{1,0}}; vector rev={0,1}; const dbl PI=acosl(-1.0); void ensure_base(int nbase){ if(nbase<=base) return; rev.resize(1<>1]>>1)+((i&1)<<(nbase-1)); rts.resize(1< &a,int n=-1){ if(n==-1) n=a.size(); assert((n&(n-1))==0); int zeros=__builtin_ctz(n); ensure_base(zeros); int shift=base-zeros; for(int i=0;i>shift)) swap(a[i],a[rev[i]>>shift]); for(int k=1;k fa; vector multiply(vector &a,vector &b){ int need=a.size()+b.size()-1; int nbase=0; while((1<(int)fa.size()) fa.resize(sz); for(int i=0;i>1);i++){ int j=(sz-i)&(sz-1); num z=(fa[j]*fa[j]-conj(fa[i]*fa[i]))*r; if(i!=j) fa[j]=(fa[i]*fa[i]-conj(fa[j]*fa[j]))*r; fa[i]=z; } fft(fa,sz); vector res(need); for(int i=0;i struct ArbitraryModConvolution{ using dbl=FFT::dbl; using num=FFT::num; vector multiply(vector as,vector bs){ int need=as.size()+bs.size()-1; int sz=1; while(sz fa(sz),fb(sz); for(int i=0;i<(int)as.size();i++) fa[i]=num(as[i].v&((1<<15)-1),as[i].v>>15); for(int i=0;i<(int)bs.size();i++) fb[i]=num(bs[i].v&((1<<15)-1),bs[i].v>>15); fft(fa,sz);fft(fb,sz); dbl ratio=0.25/sz; num r2(0,-1),r3(ratio,0),r4(0,-ratio),r5(0,1); for(int i=0;i<=(sz>>1);i++){ int j=(sz-i)&(sz-1); num a1=(fa[i]+conj(fa[j])); num a2=(fa[i]-conj(fa[j]))*r2; num b1=(fb[i]+conj(fb[j]))*r3; num b2=(fb[i]-conj(fb[j]))*r4; if(i!=j){ num c1=(fa[j]+conj(fa[i])); num c2=(fa[j]-conj(fa[i]))*r2; num d1=(fb[j]+conj(fb[i]))*r3; num d2=(fb[j]-conj(fb[i]))*r4; fa[i]=c1*d1+c2*d2*r5; fb[i]=c1*d2+c2*d1; } fa[j]=a1*b1+a2*b2*r5; fb[j]=a1*b2+a2*b1; } fft(fa,sz);fft(fb,sz); vector cs(need); using ll = long long; for(int i=0;i=md) a-=md; return a; } inline int mul(int a,int b){ return 1LL*a*b%md; } inline int pow(int a,int b){ int res=1; while(b){ if(b&1) res=mul(res,a); a=mul(a,a); b>>=1; } return res; } inline int sqrt(int a){ if(a==0) return 0; if(pow(a,(md-1)/2)!=1) return -1; int q=md-1,m=0; while(~q&1) q>>=1,m++; mt19937 mt; int z=mt()%md; while(pow(z,(md-1)/2)!=md-1) z=mt()%md; int c=pow(z,q),t=pow(a,q),r=pow(a,(q+1)/2); while(m>1){ if(pow(t,1<<(m-2))!=1) r=mul(r,c),t=mul(t,mul(c,c)); c=mul(c,c); m--; } return min(r,md-r); } template struct FormalPowerSeries{ using Poly = vector; using Conv = function; Conv conv; FormalPowerSeries(Conv conv):conv(conv){} Poly add(Poly as,Poly bs){ int sz=max(as.size(),bs.size()); Poly cs(sz,T(0)); for(int i=0;i<(int)as.size();i++) cs[i]+=as[i]; for(int i=0;i<(int)bs.size();i++) cs[i]+=bs[i]; return cs; } Poly sub(Poly as,Poly bs){ int sz=max(as.size(),bs.size()); Poly cs(sz,T(0)); for(int i=0;i<(int)as.size();i++) cs[i]+=as[i]; for(int i=0;i<(int)bs.size();i++) cs[i]-=bs[i]; return cs; } Poly mul(Poly as,Poly bs){ return conv(as,bs); } Poly mul(Poly as,T k){ for(auto &a:as) a*=k; return as; } // F(0) must not be 0 Poly inv(Poly as,int deg){ assert(as[0]!=T(0)); Poly rs({T(1)/as[0]}); int sz=1; while(szas.size()) return Poly(); reverse(as.begin(),as.end()); reverse(bs.begin(),bs.end()); int need=as.size()-bs.size()+1; Poly ds=mul(as,inv(bs,need)); ds.resize(need); reverse(ds.begin(),ds.end()); return ds; } // F(0) must be 1 Poly sqrt(Poly as,int deg){ assert(as[0]==T(1)); int sz=1; T inv2=T(1)/T(2); Poly ss({T(1)}); while(sz>n>>x; vector A(n); for(int i=0;i>A[i]; using M = mint; ArbitraryModConvolution arb; auto conv=[&](auto as,auto bs){return arb.multiply(as,bs);}; FormalPowerSeries FPS(conv); const int sz=1<<17; vector bs(sz,M(0)); rep(i,n){ bs[A[i]]+=1; } cout<