#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ppr, Vppr, greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 4010;
const int SIZE3 = 305;
const int SIZE = SIZE3;
const LL p = 998244353;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y, H, W, Q, D,T;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
LL DP[SIZE][SIZE*SIZE][3];
LL A[SIZE];
LL parent[SIZE];
bool checked[SIZE][SIZE*SIZE][3];
LL counts(int n,LL sum,int others) {
	if (sum < 0) return 0;
	if (n == 0) return sum == 0 and others==0;
	if (checked[n][sum][others]) return DP[n][sum][others];
	checked[n][sum][others] = true;
	LL ans = 0;
	if (others == 2) {
		ans = counts(n - 1, sum - A[n], 2) + counts(n - 1, sum, 1) + counts(n - 1, sum, 2)*2;
	}
	else if (others == 1) {
		ans = counts(n - 1, sum - A[n], 1) + counts(n - 1, sum, 0) + counts(n - 1, sum, 1);
	}
	else {
		ans = counts(n - 1, sum - A[n], 0);
	}
	return DP[n][sum][others] = ans%p;
}
LL solve() {
	cin >> N;
	EFOR(i, 1, N) cin >> A[i];
	LL ans = 0;
	LL sum = 0;
	EFOR(i, 1, N) sum += A[i];
	REP(i, SIZE*SIZE) {
		
		if (i >= sum-i) ans += counts(N,i,2) % p;
	//	if(counts(N,i,2) ) cout << i << " " << counts(N, i, 2) << endl;
		ans %= p;
	}
	LL types = 1;
	REP(i, N) types = types * 3 % p;
	LL two = 1;
	REP(i, N) two = two * 2 % p;
	ans = types - ans * 6 % p+3*p;
	ans -= two * 3 % p;
	ans += 6-3;
	ans += p;
	ans %= p;
	cout << ans << endl;
	return 0;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	solve();
	//	cin >> N;
	return 0;
}


Measured memory_bytes: 741376