#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N;  cin >> N;
    int S = 0;
    int mod = 998244353;
    vector<int> a(N+1,0);
    for(int i=1; i<=N; i++){
        cin >> a[i];
        S += a[i];
    }
    vector<vector<ll>> dp1(N+1, vector<ll>(S+1,0));
    dp1[0][0] = 1;
    for(int i=1; i<=N; i++){
        for(int r=0; r<=S; r++){
            dp1[i][r] = 2*dp1[i-1][r]%mod;
            if(r>=a[i]) dp1[i][r] = (dp1[i][r] + dp1[i-1][r-a[i]]) % mod;
        }
    }
    
	vector<vector<ll>> dp2(N+1, vector<ll>(S+1,0));
	dp2[0][0] = 1;
	for(int i=1; i<=N; i++){
		for(int r=0; r<=S; r++){
			dp2[i][r] = dp2[i-1][r]%mod;
			if(r>=a[i]) dp2[i][r] = (dp2[i][r] + dp2[i-1][r-a[i]]) % mod;
		}
	}

    ll ans = 1;
    for(int i=0; i<N; i++){
        ans = (ans*3)%mod;
    }
    for(int r=S/2+1; r<=S; r++){
        ans = ans - 3*dp1[N][r];
        while(ans<0) ans += mod;
        ans%=mod;
    }
    if(S%2==0){
        ans = ans - 3*dp1[N][S/2];
    	while(ans<0) ans += mod;
    	ans = (ans + 3*dp2[N][S/2]) % mod;
    }
    cout << ans << endl;
}
