#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template<int MOD>
class modint{
public:
    int a;
    modint(const long long v = 0):a(v % MOD){}
    modint operator+(const modint rhs) const{
        return modint(*this) += rhs;
    }
    modint operator-(const modint rhs) const{
        return modint(*this) -= rhs;
    }
    modint operator*(const modint rhs) const{
        return modint(*this) *= rhs;
    }
    modint operator/(const modint rhs) const{
        return modint(*this) /= rhs;
    }
    modint &operator+=(const modint rhs){
        a += rhs.a;
        if(a >= MOD){
            a -= MOD;
        }
        return *this;
    }
    modint &operator-=(const modint rhs){
        if(a < rhs.a){
            a += MOD;
        }
        a -= rhs.a;
        return *this;
    }
    modint &operator*=(const modint rhs){
        a = (long long)a * rhs.a % MOD;
        return *this;
    }
    modint &operator/=(const modint rhs){
        
        return *this;
    }
    //https://mickey24.hatenablog.com/entry/20081021/1224590753
    modint &operator++(){
        *this += 1;
        return *this;
    }
    modint &operator--(){
        *this -= 1;
        return *this;
    }
    modint operator++(int){
        modint res = *this;
        res += 1;
        return res;
    }
    modint operator--(int){
        modint res = *this;
        res -= 1;
        return res;
    }
    modint &operator+=(const long long rhs){
        *this += modint(rhs);
        return *this;
    }
    modint &operator-=(const long long rhs){
        *this -= modint(rhs);
        return *this;
    }
    modint &operator*=(const long long rhs){
        *this *= modint(rhs);
        return *this;
    }
    modint &operator/=(const long long rhs){
        *this /= modint(rhs);
        return *this;
    }
    modint operator+() const{
        return *this;
    }
    modint operator-() const{
        return modint()-*this;
    }
    bool operator==(const modint rhs) const{
        return a == rhs.a;
    }
    bool operator==(const long long rhs) const{
        return a == rhs;
    }
    bool operator!=(const modint rhs) const{
        return a != rhs.a;
    }
    bool operator!=(const long long rhs) const{
        return a != rhs;
    }
    
};
using mint = modint<998244353>;
mint dp[301][300*305];
mint dp2[301][300*305];
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    ll sum = accumulate(a.begin(),a.end(),0LL);
    mint ans = 1;
    rep(i,n)ans *= 3;
    mint inv2 = (998244353+1)/2;
    mint po = 1;
    rep(i,n)po *= 2;
    dp[0][0] = dp2[0][0] = 1;
    rep(i,n){
        rep(j,n*300+1){
            if(dp[i][j].a){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j+a[i]] += dp[i][j] * inv2;
                dp2[i+1][j] += dp2[i][j];
                dp2[i+1][j+a[i]] += dp2[i][j];
            }
        }
    }
    rep(j,300*n+1){
        if(dp[n][j].a and sum - j <= j){
            ans -= po * 3 * dp[n][j];
            if(sum - j == j){
                ans += mint(3) * dp2[n][j];
            }
        }
    }
    cout << ans.a << endl;
}


Measured memory_bytes: 215672