#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=320,M=N*N,mo=998244353;

int n,a[N];
ll f[M],g[M];

int main()
{
	scanf("%d",&n);
	int zh=0;
	fo(i,1,n)scanf("%d",&a[i]),zh=zh+a[i];
	int ha=(zh+1)>>1;
	int lj=0;
	f[0]=g[0]=1;
	fo(i,1,n){
		lj=lj+a[i];
		fd(l,lj,a[i])f[l]=(f[l]*2+f[l-a[i]])%mo,g[l]=(g[l]+g[l-a[i]])%mo;
		fd(l,a[i]-1,0)f[l]=f[l]*2%mo;
	}
	ll ans=0;
	fo(l,ha,zh)ans=(ans+f[l])%mo;
	ll zg=1;
	fo(i,1,n)zg=zg*3%mo;
	ans=(mo+zg-ans*3%mo)%mo;
	if(ha*2==zh)ans=(ans+3*g[ha])%mo;
	cout<<ans;
}