# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;
const long long md = 998244353;


int n;
int a[305];
int dp3[305][10];
int dp[2][2 * 305 * 305];


long long get_all() {
    dp3[0][0] = 1;
    int msk;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 8; ++j) {
            for (int k = 0; k < 3; ++k) {
                msk = (j | (1 << k));
                dp3[i][msk] += dp3[i - 1][j];
                if (dp3[i][msk] >= md) dp3[i][msk] -= md;
            }
        }
    }
    return dp3[n][7];
}

long long solve() {
    int x = 0, y = 1;
    dp[x][0] = 1;
    int s = 0;
    for (int i = 1; i <= n; ++i) {
        swap(x, y);
        memset(dp[x], 0, sizeof(dp[x]));
        for (int j = 0; j <= (i - 1) * 300; ++j) {
            dp[x][j + a[i]] += dp[y][j];
            if (dp[x][j + a[i]] >= md) dp[x][j + a[i]] -= md;
            dp[x][j + a[i]] += dp[y][j];
            if (dp[x][j + a[i]] >= md) dp[x][j + a[i]] -= md;
            dp[x][j] += dp[y][j];
            if (dp[x][j] >= md) dp[x][j] -= md;
        }
        s += a[i];
    }
    for (int i = 1; i <= n; ++i) {
        dp[x][a[i]] -= 2;
        if (dp[x][a[i]] < 0) dp[x][a[i]] += md;
    }
    long long res = 0;
    for (int i = 1; i <= n * 300; ++i) if (i <= s - i && dp[x][i]) {
        res += dp[x][i];
        if (res >= md) res -= md;
//        cout << ">" << i << " " << dp[x][i] << '\n';
    }
//    res *= 2ll;
  //  res %= md;
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j <= s; ++j)
            dp[i][j] = 0;
    x = 0, y = 1;
    dp[x][0] = 1;
    for (int i = 1; i <= n; ++i) {
        swap(x, y);
        memset(dp[x], 0, sizeof(dp[x]));
        for (int j = 0; j <= (i - 1) * 300; ++j) {
            dp[x][j + a[i]] += dp[y][j];
            if (dp[x][j + a[i]] >= md) dp[x][j + a[i]] -= md;
            dp[x][j] += dp[y][j];
            if (dp[x][j] >= md) dp[x][j] -= md;
        }
    }
    for (int i = 1; i <= n; ++i) {
        dp[x][a[i]]--;
        if (dp[x][a[i]] < 0) dp[x][a[i]] += md;
    }
    long long res2 = 0;
    for (int i = 1; i <= n * 300; ++i) if (i <= s - i && dp[x][i]) {
        res2 += dp[x][i];
//        cout << ">" << i << " " << dp[x][i] << '\n';
        if (res2 >= md) res2 -= md;
    }
    res2 *= 2ll;
    res2 %= md;
    res -= res2;
    if (res < 0) res += md;
    res *= 3ll;
    res %= md;
    return res;
}

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    long long res = get_all() - solve();
    if (res < 0) res += md;
    cout << res << '\n';
}



Measured memory_bytes: 1792