#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 998244353


//ここから編集する
class Combination {

public:
    vector<ll> fact;

    Combination(int max_n) {
        //1 ~ n!までの階乗modを求める
        int n = max_n;
        vector<ll> fact(n + 1);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i - 1] * i) % MOD;
        }
        this->fact = fact;
    }

    template<typename T>
    //templateをつかってみｔか
    ll pow(T x, int y) {
        if (y == 0) return 1;
        if (y == 1) return x;
        if (y == 2) return (x * x) % MOD;
//        if (y % 2 == 1) return pow(x, y / 2) * pow(x, y / 2) % MOD;
        if (y % 2 == 1) return pow(pow(x, y / 2), 2) * x % MOD;
//        return pow(x, y / 2) * pow(x, y / 2) % MOD;
        return pow(pow(x, y / 2), 2) % MOD;
    }

    ll nCk(int n, int k) {
//        return (fact[n] * pow(fact[n-k],MOD-2) * pow(fact[k],MOD-2)) % MOD;
        return (((fact[n] * pow(fact[n - k], MOD - 2)) % MOD) * pow(fact[k], MOD - 2)) % MOD;
    }

    /**
     * x ^ -1を求める
     */
    template<typename T>
    ll inv(T x) {
        return pow(x, MOD - 2);
    }
};

int N;
vector<int> a;

void input() {
    cin >> N;
    a.resize(N);
    sort(all(a));
//    reverse(all(a));
    rep(i, 0, N) cin >> a[i];
}

int main() {
    input();
    Combination cmb(2);
//    vector<ll> t1(90001);
    ll t1[90001] = {};
    t1[0] = cmb.pow(2, N);
    ll max_idx = 0;
    ll inv2 = cmb.inv(2);
    for (int i = 0; i < N; ++i) {
        for (int j = max_idx; j >= 0; j--) {
            if (t1[j] > 0) {
                ll add = t1[j];
                add *= inv2;
                if (j + a[i] < 90001) {
//                        t1[j + a[i]] = ((t1[j + a[i]] + add) % MOD + MOD) % MOD;
                    t1[j + a[i]] = (t1[j + a[i]] + add) % MOD;
                    chmax(max_idx, j + a[i]);
                }
            }
        }
    }

    vector<ll> t2(90001);
    t2[0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = (int) t2.size() - 1; j >= 0; j--) {
            if (t2[j] > 0) {
                if (j + a[i] < t2.size()) {
                    t2[j + a[i]] = (t2[j + a[i]] + t2[j]) % MOD;
                }
            }
        }
    }

    ll sum = accumulate(all(a), 0ll);
    ll tapi = 0ll;
    ll tapya = (3 * cmb.pow(2, N)) % MOD;
    ll tapu = 0ll;

    for (int i = 0; i <= sum; ++i) {
        if (i * 2 >= sum) {
            tapi += 3 * t1[i];
            tapi %= MOD;

            tapu += 6 * t2[i];
            tapu %= MOD;
        }
    }

    ll sub = (tapi + tapya - tapu) % MOD;
    if (sub < 0) sub += MOD;
    ll ans = cmb.pow(3, N);
    ans -= sub;
    ans %= MOD;
    if (ans < 0) ans += MOD;

    cout << ans << endl;

    return 0;

}




Measured memory_bytes: 1792