#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int llint;
llint v[1000005],dp[1000005],n;
int x[25][25];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			cin >> x[i][j];
		}
	}
	for(int i=0;i<(1 << n);i++) {
		for(int j=0;j<n;j++) {
			for(int k=j+1;k<n;k++) {
				v[i]+=((i & (1 << j)) && (i & (1 << k)))*x[j][k];
			}
		}
	}
	for(int i=0;i<(1 << n);i++) {
		dp[i]=max(dp[i],v[i]);
		for(int j=i;j>0;j=(j-1) & i) {
			dp[i]=max(dp[i],dp[j]+dp[i ^ j]);
		}
	}
	cout << dp[(1 << n)-1];
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 998244353;
const ll MAXN = 303;


ll dp[MAXN][MAXN*MAXN];

main(){
	int n;
	cin >> n;
	ll arr[n];
	int S = 0;
	for(int i=0;i<n;++i){
		cin >> arr[i];
		S += arr[i];
	}
	fill(&dp[0][0], &dp[0][0] + MAXN*MAXN*MAXN, 0);
	dp[0][0] = 1;
	for(auto i=0;i<n;++i){
		for(auto j=0;j<MAXN*MAXN;++j){
			dp[i+1][j+arr[i]] += dp[i][j];
			dp[i+1][j+arr[i]]%=MOD;
			dp[i+1][j] += 2LL*dp[i][j];
			dp[i+1][j]%=MOD;
		}
	}
	ll K = 0;
	for(auto i=(S+1)/2;i<=S;++i){
		K += dp[n][i];
	}
	fill(&dp[0][0], &dp[0][0] + MAXN*MAXN*MAXN, 0);
	dp[0][0] = 1;
	ll L = 0;
	if(S%2==0){
		for(auto i=0;i<n;++i){
			for(auto j=0;j<MAXN*MAXN;++j){
				dp[i+1][j+arr[i]] += dp[i][j];
				dp[i+1][j+arr[i]]%=MOD;
				dp[i+1][j] += dp[i][j];
				dp[i+1][j]%=MOD;
			}
		}
		L = dp[n][S/2];
	}
	ll ans = 1;
	for(int i=0;i<n;++i){
		ans *= 3LL;
		ans %= MOD;
	}
	ans += MOD - (3*K)%MOD;
	ans %=MOD;
	ans += 3*L;
	ans %=MOD;
	cout << ans << endl;
}
