import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T read(T)(){ return read.to!T; }
T[] read(T)(long n){ return n.iota.map!(_ => read!T).array; }
T[][] read(T)(long m, long n){ return m.iota.map!(_ => read!T(n)).array; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

/*

終了後(ネタバレ見た)

xs[k][i]: i番目までを使い、赤の和がkである場合の数
ys[k][i]: i番目までを使い、赤の和がk、青の和が0である場合の数


求めるものは
s := sum(i; 0 .. n) a[i]
u = 3 sum(k: (s - 1) / 2 .. s + 1) xs[k][n - 1]
sが偶数の場合更に u -= 3 ys[s / 2][n - 1]

ans = 3 ** n - u

xs[0][0] = 2
xs[a[0]][0] = 1
xs[k][i] = xs[k][i - 1] * 2 + xs[k - a[i]][i - 1]

ys[0][0] = 1
ys[a[0]][0] = 1
ys[k][i] = ys[k][i - 1] + ys[k - a[i]][i - 1]

*/
const long mod = 998244353;

void solve(){
	long n = read!long;
	long[] as = read!long(n);
	
	long sum = as.sum;
	log("sum:", sum);
	
	long[][] xs = new long[][](sum + 1, n);
	long[][] ys = new long[][](sum + 1, n);
	foreach(k; 0 .. sum + 1) foreach(i; 0 .. n){
		if(i == 0){
			if(k == 0) xs[k][i] = 2, ys[k][i] = 1;
			else if(k == as[0]) xs[k][i] = 1, ys[k][i] = 1;
		}
		else{
			long x = (xs[k][i - 1] * 2) % mod;
			if(k - as[i] >= 0) x += xs[k - as[i]][i - 1], x %= mod;
			xs[k][i] = x;
			long y = ys[k][i - 1];
			if(k - as[i] >= 0) y += ys[k - as[i]][i - 1], y %= mod;
			ys[k][i] = y;
		}
	}
	log("xs:", xs);
	log("ys:", ys);
	log("xs[-][n - 1]:", xs.map!(q => q[$ - 1]));
	log("ys[-][n - 1]:", ys.map!(q => q[$ - 1]));
	
	long u;
	foreach(k; (sum + 1) / 2 .. sum + 1) u += 3 * xs[k][n - 1], u %= mod;
	if(sum % 2 == 0) u += mod - 3 * ys[sum / 2][n - 1], u %= mod;
	log("u:",u);
	
	long pow3 = 1;
	foreach(i; 0 .. n) pow3 *= 3, pow3 %= mod;
	log("pow3:", pow3);
	
	long ans = (pow3 + mod - u) % mod;
	ans.writeln;
}
