#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000001



int main(){
	
	int N;
	cin>>N;
	
	int sum = 0;
	
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
		sum += a[i];
	}
	
	vector<vector<int>> dp(N+1,vector<int>(sum+1,0));
	dp[0][0] = 1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=sum;j++){
			dp[i+1][j] = mod(dp[i+1][j] + mod(dp[i][j]*2));
			int x = j+a[i];
			if(x>sum)continue;
			dp[i+1][x] = mod(dp[i+1][x]+dp[i][j]);
		}
	}
	
	int ans = 0;
	
	for(int i=(sum+1)/2;i<=sum;i++){
		ans = mod(ans + dp.back()[i]);
		//cout<<i<<':'<<dp.back()[i]<<endl;
	}
	
	ans = mod(ans * 3);
	
	vector<vector<int>> dp2(N+1,vector<int>(sum+1,0));
	dp2[0][0] = 1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=sum;j++){
			dp2[i+1][j] = mod(dp2[i+1][j] + dp2[i][j]);
			int x = j+a[i];
			if(x>sum)continue;
			dp2[i+1][x] = mod(dp2[i+1][x]+dp2[i][j]);
		}
	}
	
	if(sum%2==0){
		int d = dp2.back()[sum/2];
		d = mod(d*3);
		ans = mod(ans-d);
	}
	
	int x = 1;
	for(int i=0;i<N;i++){
		x = mod(x*3);
	}
	
	ans = mod(x-ans);
	
	cout<<ans<<endl;
	
    return 0;
}
