//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL powmod(LL x, LL n, LL mod) {
	LL ret = 1;
	while (n > 0) {
		if (n & 1) (ret *= x) %= mod;
		(x *= x) %= mod;
		n >>= 1;
	}
	return ret;
}

LL extgcd(LL a, LL b, LL &x, LL &y) {
	LL g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
LL invMod(LL a, LL m) {
	LL x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m; return 0;
}

int main() {
	int n; cin >> n;
	vector<int> a(n);
	LL m = 998244353;
	LL s = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
	}

	LL l = 0;
	if (s % 2 == 0) {
		l = s / 2;
	}
	else {
		l = s / 2 + 1;
	}


	//色cの値がs/2以上の場合の数。
	//R>s/2である場合は共通部分がないので、Rの値だけおぼえて置けばdpできる
	vector<vector<LL>> dp(n + 1, vector<LL>(l + 1));

	dp[0][0] = 1;


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l + 1; j++) {

			//Rを取る
			if (j + a[i] >= l) {
				dp[i + 1][l] += dp[i][j];
				dp[i + 1][l] %= m;
			}
			else {
				dp[i + 1][j + a[i]] += dp[i][j];
				dp[i + 1][j + a[i]] %= m;
			}

			//B,Gを取る
			dp[i + 1][j] += (dp[i][j] * 2LL) % m;

			dp[i + 1][j] %= m;
		}
	}

	LL ans1 = dp[n][l];

	LL ans2 = 0;
	//2色がs/2になるときが上の中で重複してるので引いてあげる
	if (s % 2 == 0) {
		vector<vector<LL>> dp2(n + 1, vector<LL>(s + 1));

		dp2[0][0] = 1;


		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l + 1; j++) {

				//Rにする
				if (j + a[i] <= s) {
					dp2[i + 1][j + a[i]] += dp2[i][j];
					dp2[i + 1][j + a[i]] %= m;
				}
				
				//Bにする
				dp2[i + 1][j] += dp2[i][j];

				dp2[i + 1][j] %= m;
			}
		}

		ans2 = dp2[n][l];
	}

	LL base = powmod(3LL, n, m);

	LL ans = (base - (ans1 * 3LL) % m + m) % m;

	ans += (((ans2 * 3LL) % m)) % m;
	ans = (ans + m) % m;

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 318752