#include <iostream>

using namespace std;

typedef long long ll;

const ll mod = 998244353;

int n;
int a[305];
ll dp[305][90005];
ll dp2[305][90005];

ll p(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

int main() {
  cin >> n;
  int sum = 0;
  int maxa = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    maxa = max(maxa,a[i]);
  }

  dp[0][0] = 1;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= i * maxa; j++) {
      if(dp[i][j] == 0) continue;
      dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 2) % mod;
      dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j]) % mod;
			 
    }
  }
  dp2[0][0] = 1;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= i * maxa; j++) {
       if(dp2[i][j] == 0) continue;
      dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j]) % mod;
      dp2[i+1][j+a[i]] = (dp2[i+1][j+a[i]] + dp2[i][j]) % mod;
    }
  }

  ll ans = p(3,n);
  for(int i = 0; i <= n * maxa; i++) {
    if(i >= sum - i) {
      ans = (ans + mod - dp[n][i] * 3 % mod) % mod;
    }
    if(i == sum - i) {
      ans = (ans + dp2[n][i] * 3 % mod) % mod;
    }
  }
  if(ans < 0 ) cout << ans + mod << endl;
  else 
  cout << ans << endl;
}
				 
  
  


  
  

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 998244353;

void add(ll& a, ll b) { a = (a+b) % MOD; }
void mul(ll& a, ll b) { a = (a*b) % MOD; }

int main() {
    int N, A[300];
    cin >> N;
    int sm = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sm += A[i];
    }

    const int MX = 300 * 300;
    static ll dp[301][MX + 301], sub[301][MX + 301];
    dp[0][0] = 1;
    sub[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= MX; j++) {
            add(dp[i + 1][j + A[i]], dp[i][j]);
            add(dp[i + 1][j], 2 * dp[i][j]);
            add(sub[i + 1][j + A[i]], sub[i][j]);
            add(sub[i + 1][j], sub[i][j]);
        }
    }

    ll ng = 0;
    for (int j = (sm + 1) / 2; j <= MX; j++) add(ng, dp[N][j]);
    if (sm % 2 == 0) add(ng, MOD - sub[N][sm / 2]);
    mul(ng, 3);

    ll ans = 1;
    for (int i = 0; i < N; i++) mul(ans, 3);
    add(ans, MOD - ng);

    cout << ans << endl;
    return 0;
}