#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

using int64 = int_fast64_t;
template<int64 MOD>
struct ModInt{
    int64 x;
    ModInt():x(0){}
    ModInt(int64 x):
        x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
        {}
    // 負号
    ModInt operator -() const{
        return ModInt(-x);
    }
    // 加算
    ModInt &operator +=(const ModInt &rhs){
        x+=rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator +(const ModInt &rhs) const{
        return ModInt(*this)+=rhs;
    }
    // 減算
    ModInt &operator -=(const ModInt &rhs){
        x+=MOD-rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator -(const ModInt &rhs) const{
        return ModInt(*this)-=rhs;
    }
    // 乗算
    ModInt &operator *=(const ModInt &rhs){
        x*=rhs.x;
        if(x>=MOD) x%=MOD;
        return (*this);
    }
    ModInt operator *(const ModInt &rhs) const{
        return ModInt(*this)*=rhs;
    }
    // 除算
    ModInt &operator /=(const ModInt &rhs){
        (*this)*=rhs.inverse();
        return (*this);
    }
    ModInt operator /(const ModInt &rhs) const{
        return ModInt(*this)/=rhs;
    }
    // 等号
    bool operator ==(const ModInt &rhs){
        return x==rhs.x;
    }
    bool operator !=(const ModInt &rhs){
        return x!=rhs.x;
    }
    // 累乗
    ModInt pow(int64 n){
        int64 tmp=x;
        x=1;
        while(n>0){
            if(n&1) x=x*tmp%MOD;
            tmp=tmp*tmp%MOD;
            n>>=1ll;
        }
        return (*this);
    }
    // 逆元
    ModInt inverse(){
        int64 a=x,b=MOD,s=1,t=0;
        while(b>0){
            int64 u=b/a;
            b-=u*a;
            t-=u*s;
            swap(a,b);
            swap(s,t);
        }
        return ModInt(s);
    }
    // 入出力
    friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
        int64 x; lhs>>x;
        rhs=ModInt<MOD>(x);
        return lhs;
    }
    friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
        return lhs<<rhs.x;
    }
};

using mint=ModInt<LMOD>;
// dp[i][j]:=iまで見てRの和がjとなる
mint dp[310][310*300];
// dp1[i][j]:=iまで見てRの和がjかつGの和がsi-j
mint dp1[310][310*300];
int main(){
    int n; cin>>n;
    int a[n],s=0;
    rep(i,n){
        cin>>a[i];
        s+=a[i];
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<310*300;j++){
            // GorB
            dp[i][j]+=dp[i-1][j]*2;
            // R
            if(j-a[i-1]>=0) dp[i][j]+=dp[i-1][j-a[i-1]];
        }
    }
    dp1[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<310*300;j++){
            // G
            dp1[i][j]+=dp1[i-1][j];
            // R
            if(j-a[i-1]>=0) dp1[i][j]+=dp1[i-1][j-a[i-1]];
        }
    }
    mint sum=3;
    sum.pow(n);
    for(int i=(s+1)/2;i<310*300;i++){
        // if(dp[n][i]!=0) cout<<i<<" "<<dp[n][i]*3<<endl;
        sum-=dp[n][i]*3;
    }
    if(s%2==0) sum+=dp1[n][s/2]*3;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 450688