#include using namespace std; #define ll long long #define lll long long//__int128 #define pii pair //#define f first //#define s second # define PI 3.14159265358979323846 #include using namespace __gnu_pbds; struct chash_key { ll operator()(pii x) const { return (ll)x.first*1000000000 + x.second; } }; //gp_hash_table hs[2],p[2]; //gp_hash_table dp; struct P { int x,y; bool operator <(const P &a) const { //if(y!=a.y) //return ya.y; } bool operator <=(const P &a)const { return (x<=a.x&&y<=a.y); } P operator +(const P &a)const { return {x+a.x,y+a.y}; } }; const ll mod=998244353,pp=999630629; ll tw[111111]; int cnt[11111],a; ll x=0; int main() { tw[0]=1; for(int t=1;t<=100000;t++) { tw[t]=tw[t-1]*2; if(tw[t]>=mod) tw[t]-=mod; } scanf("%d",&a); for(int t=1;t<=a;t++) { int s; scanf("%d",&s); cnt[s]++; x+=s; } ll ans=0; ll d=0; if(x>=pp) d=1; for(int t=1;t<=10000;t++) { ans+=tw[a-1]*t%mod*cnt[t]%mod; if(ans>=mod) ans-=mod; if(x-t>=pp) d+=cnt[t]; if(x-t*2>=pp) { d+=(ll)cnt[t]*(cnt[t]-1)/2; } if(x-t*3>=pp) { d+=(ll)cnt[t]*(cnt[t]-1)*(cnt[t]-2)/6; } d%=mod; } for(int t=1;t<=10000;t++) cnt[t]+=cnt[t-1]; for(int t=10000;t>=1;t--) { if(x-t*2>=pp) { d+=(ll)(cnt[t]-cnt[t-1])*cnt[t-1]; //d+=(ll)(cnt[t]-1-cnt[t-1])*(cnt[t]-cnt[t-1]); } else if(x-t>pp) { d+=(ll)(cnt[t]-cnt[t-1])*cnt[x-t-pp]; } d%=mod; } for(int i=10000;i>=1;i--) for(int j=i;j>=1;j--) if(x-i-j>pp) { if(x-i-j-pp