#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
//three colors

const int mod = 998244353;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  bool operator>(const ModInt &p) const {return this->x>p.x;}
  
  bool operator>(const int p) const {return this->x>p;}
  
  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector<vector<modint>> dp(n*300+1,vector<modint>(3,0));
  vector<vector<modint>> dp2(n*300+1,vector<modint>(3,0));
  dp[0][0] = 1;
  dp2[0][0] = 1;
  rep(i,n){
    vector<vector<modint>> ndp(sum+a[i]+1,vector<modint>(3,0));
    vector<vector<modint>> ndp2(sum+a[i]+1,vector<modint>(3,0));
    rep(j,sum+1){
      rep(l,3){
	ndp[j+a[i]][l] += dp[j][l];
	ndp2[j+a[i]][l] += dp2[j][l];	
	ndp2[j][min(l+1,2)] += dp2[j][l];
	if(l!=0){
	  ndp[j][min(l+1,2)] += dp[j][l]*2;	  
	}
	else{
	  ndp[j][min(l+1,2)] += dp[j][l];
	}
      }
    }
    sum += a[i];
    rep(j,sum+1){
      rep(l,3){      
	dp[j][l] = ndp[j][l];
	dp2[j][l] = ndp2[j][l];
      }    
    }

  }
  //  cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << "s"<<endl;  
  modint x = 3;
  modint y = 2;
  modint ans = x.pow(n);
  ans -= (x + x*(y.pow(n)-y));
  for(int i= (sum+1)/2; i<=n*300; i++){
    ans -= (dp[i][2]-dp2[i][2])*6;    
  }
  cout << ans << endl;
  //  cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << "s"<<endl;
  return 0;
    

}


Measured memory_bytes: 19868