#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const int MOD=998244353;

struct mint {
  unsigned x;
  inline int _norm(int x) {
    if (x<0) x+=MOD;
    return x;
  }
  mint() : x(0) {}
  mint(signed sig) {sig=_norm(sig); x=sig;}
  mint(signed long long sig) {sig=_norm(sig%MOD); x=sig;}
  int get() const { return (int)x; }
 
  mint &operator+=(mint that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
  mint &operator-=(mint that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
  mint &operator*=(mint that) { x = ((unsigned long long)x * that.x) % MOD; return *this; }
  mint &operator/=(mint that) { return *this *= that.inverse(); }

  mint &operator+=(int that) {that=_norm(that); if((x += that) >= MOD) x -= MOD; return *this; }
  mint &operator-=(int that) {that=_norm(that); if((x += MOD - that) >= MOD) x -= MOD; return *this; }
  mint &operator*=(int that) {that=_norm(that); x = ((unsigned long long)x * that) % MOD; return *this; }
  mint &operator/=(int that) {that=_norm(that); return *this *= mint(that).inverse(); }

  mint operator+(mint that) const { return mint(*this) += that; }
  mint operator-(mint that) const { return mint(*this) -= that; }
  mint operator*(mint that) const { return mint(*this) *= that; }
  mint operator/(mint that) const { return mint(*this) /= that; }

  mint operator+(int that) const { return mint(*this) += that; }
  mint operator-(int that) const { return mint(*this) -= that; }
  mint operator*(int that) const { return mint(*this) *= that; }
  mint operator/(int that) const { return mint(*this) /= that; }


  mint inverse() const {
    signed a = x, b = MOD, u = 1, v = 0;
    while(b) {
      signed t = a / b;
      a -= t * b; std::swap(a, b);
      u -= t * v; std::swap(u, v);
    }
    if(u < 0) u += MOD;
    mint res; res.x = (unsigned)u;
    return res;
  }
 
  bool operator==(mint that) const { return x == that.x; }
  bool operator!=(mint that) const { return x != that.x; }
  mint operator-() const { mint t; t.x = x == 0 ? 0 : MOD - x; return t; }
  mint operator^(unsigned long long k) const {
    // 0^0 is 1. k must be taken modulo phi(MOD) (MOD-1 if prime) and NOT MOD itself
    mint a=(*this);
    mint r = 1;
    while(k) {
      if(k & 1) r *= a;
      a *= a;
      k >>= 1;
    }
    return r;
  }
};

const int mx=302*302;
mint f[2][2*mx];
void solve(long long _n, vector<long long> _a){
  int n=_n; vector<int> a(n); for (int i=0;i<n;i++) a[i]=_a[i];
  int cur=0,nxt=1;
  f[cur][mx]=1;
  for (int p=0;p<n;p++) {
  	memset(f[nxt],0,sizeof f[nxt]);
  	int ap=a[p];
  	for (int x=0;x<2*mx;x++) {
  		mint val=f[cur][x];
  		if (val.get()!=0) {
  			f[nxt][x+ap]+=val;
  			f[nxt][x-ap]+=val*2;
  		}
  	}
  	swap(cur,nxt);
  }
  mint bad=0;
  for (int x=mx;x<2*mx;x++) bad+=f[cur][x];

  memset(f,0,sizeof f); cur=0,nxt=1;
  f[cur][mx]=1;
  for (int p=0;p<n;p++) {
  	memset(f[nxt],0,sizeof f[nxt]);
  	int ap=a[p];
  	for (int x=0;x<2*mx;x++) {
  		mint val=f[cur][x];
  		if (val.get()!=0) {
  			f[nxt][x+ap]+=val;
  			f[nxt][x-ap]+=val;
  		}
  	}
  	swap(cur,nxt);
  }
 	mint anti=f[cur][0+mx];
  //printf("anti:%lld\n",anti);
  bad-=anti;
  bad*=3;
	mint all=1; for (ll i=0;i<n;i++) all*=3;
	mint good=all-bad;
	printf("%d\n",good.get());
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



Measured memory_bytes: 1664