#include #if __has_include() #include #include #include #endif using namespace std; #define eb emplace_back #define done(...) return pp(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define RDVL(T,n,...) vec__VA_ARGS__;fe(refs(__VA_ARGS__),e)e.get().resizes(n);lin(__VA_ARGS__) #define VL(n,...) RDVL(ll,n,__VA_ARGS__) #define fo(i,...) for(auto[i,i##stop,i##step]=for_range(0,__VA_ARGS__);ivoid pp(const auto&...a){[[maybe_unused]]const char*c="";((o<(a...);} #define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{ #define use_ml998244353 using ml=atcoder::modint998244353; namespace my{ auto&operator<<(ostream&o,const atcoder::modint998244353&x){return o<<(int)x.val();} void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<concept modulary=requires(T t){t.mod();}; constexpr auto refs(auto&...a){return array{ref(a)...};} templateconstexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} templateconstexpr auto for_range(T s,T a,T b,T c=1){return array{a-s,b,(1-s*2)*c};} void lin(auto&...a){(cin>>...>>a);} constexpr ll powm1(ll n){return 1-2*(n&1);} auto min(auto...a){return min(initializer_list>{a...});} templatestruct pair{ A a;B b; pair()=default; pair(A aa,B bb):a(aa),b(bb){} auto operator<=>(const pair&)const=default; }; templateusing pack_back_t=tuple_element_t>; } namespace my{ templateconcept vectorial=is_base_of_v::value_type>,remove_cvref_t>; templateistream&operator>>(istream&i,vector&v){fe(v,e)i>>e;return i;} templateconstexpr int depth=0; templateconstexpr int depth =depth+1; templatestruct core_t_helper{using type=T;}; templateusing core_t=core_t_helper::type; templatestruct vec; templatestruct hvec_helper{using type=vec::type>;}; templatestruct hvec_helper<0,T>{using type=T;}; templateusing hvec=hvec_helper::type; templatestruct vec:vector{ static constexpr int D=depth>; using C=core_t; using vector::vector; vec(const vector&v):vector(v){} void resizes(const auto&...a){if constexpr(sizeof...(a)==D)*this=make(a...,C{});else{ }} static auto make(ll n,const auto&...a){ if constexpr(sizeof...(a)==1)return vec(n,array{a...}[0]); else { } } ll size()const{return vector::size();} auto&emplace_back(auto&&...a){vector::emplace_back(std::forward(a)...);return*this;} auto fold(const auto&f)const{ pairr{}; fe(*this,e){ if constexpr(!vectorial){ if(r.b)f(r.a,e); else r={e,1}; }else { } } return r; } auto sum()const{return fold([](auto&a,const auto&b){a+=b;}).a;} auto max()const{return fold([](auto&a,auto b){if(a){ }fo(i,v.size()-1)v[i+1]+=v[i];return v;} auto count_enumerate(C M=-1)const{ assert(min()>=0); if(M==-1)M=max(); vecres(M+1); auto f=[&](auto&f,const vec&v){ fe(v,e){ if constexpr(vectorial){ } else if(e<=M)res[e]++; } }; f(f,*this); return res; } }; templaterequires(sizeof...(A)>=2)vec(const A&...a)->vec>>; } namespace my{ templateauto inv_enumerate(ll n){ vecv(n+1); v[0]=0; if(n>=1)v[1]=1; fo(i,2,n+1)v[i]=-v[T::mod()%i]*(T::mod()/i); return v; } } namespace my{ templateT inv(ll n){static vecv{0,1};if(ll m=v.size();m<=n){v.resize(n+1);fo(i,m,n+1)v[i]=-v[T::mod()%i]*(T::mod()/i);}return v[n];} } namespace my{ templatestruct formal_power_series:vec{ using vec::vec; using fps=formal_power_series; static constexpr ll SPARSE_THRESHOLD=20; static fps mul(const fps&a,const fps&b){ if constexpr(!modulary){ } else if constexpr(is_same_v)return atcoder::convolution(a,b); else { } } fps pre(ll deg)const{fps r(this->begin(),this->begin()+min(this->size(),deg));r.resize(deg);return r;} fps&operator-=(const fps&g){if(g.size()>this->size())this->resize(g.size());fo(i,g.size())(*this)[i]-=g[i];return*this;} fps&operator*=(const fps&g){return*this=(this->size()&&g.size()?mul(*this,g):fps{});} binary_operator(-,fps) binary_operator(*,fps) fps operator-()const{auto r=*this;fe(r,x)x=-x;return r;} fps&operator+=(const T&c){if(!this->size())this->resize(1);(*this)[0]+=c;return*this;} fps&operator*=(const T&c){fo(i,this->size())(*this)[i]*=c;return*this;} binary_operator(+,T) binary_operator(*,T) fps differential()const{ assert(this->size()); fps r(this->size()-1); fo(i,r.size())r[i]=(*this)[i+1]*T{i+1}; return r; } fps integral()const{ fps r(this->size()+1); auto iv=inv_enumerate(r.size()); fo(i,r.size()-1)r[i+1]=(*this)[i]*iv[i+1]; return r; } fps inv_sparse(ll deg=-1)const{ assert((*this)[0]!=T{}); ll n=this->size(); if(deg==-1)deg=n; vec>p; fo(i,1,n)if((*this)[i]!=T{})p.eb(i,(*this)[i]); fps r(deg); r[0]=T{1}/(*this)[0]; fo(i,1,deg){ T t{}; fe(p,k,fk){ if(i-k<0)break; t-=fk*r[i-k]; } r[i]=r[0]*t; } return r; } fps exp_sparse(ll deg=-1)const{ assert((*this)[0]==T{}); ll n=this->size(); if(deg==-1)deg=n; vec>p; fo(i,1,n)if((*this)[i]!=T{})p.eb(i-1,T{i}*(*this)[i]); auto iv=inv_enumerate(deg); fps r(deg); r[0]=1; fo(i,1,deg){ T t{}; fe(p,k,fk){ if(i-k-1<0)break; t+=fk*r[i-k-1]; } r[i]=t*iv[i]; } return r; } ll nonzero_terms_count()const{ll r=0;fe(*this,e)r+=(e!=T{});return r;} fps inv(ll deg=-1)const{ assert((*this)[0]!=T{}); if(deg==-1)deg=this->size(); if(nonzero_terms_count()pre(i<<1)*(r*r)).pre(i<<1); return r.pre(deg); } fps log(ll deg=-1)const{ assert((*this)[0]==T{1}); if(deg==-1)deg=this->size(); return(differential()*inv(deg)).integral().pre(deg); } fps exp(ll deg=-1)const{ assert((*this)[0]==T{}); if(deg==-1)deg=this->size(); if(nonzero_terms_count()pre(i<<1)+T{1}-r.log(i<<1))).pre(i<<1); return r.pre(deg); } }; templateusing fps=formal_power_series; } namespace my{entry void main(){ LL(N); VL(N,a); ll P=999630629; ll S=a.sum(); ll M=S-P+1; use_ml998244353 if(M<=1)done(ml(2).pow(N-1)*S); auto c=a.count_enumerate(M); fpsf(M); fo(j,1,M){ fo(n,1,(M-1)/j+1){ f[j*n]+=c[j]*powm1(n)*inv(n); } } f=(-f).exp(); f=f.zeta(); pp(ml(2).pow(N-1)*S-P*f[M-1]); }}