#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=16,M=1e9+7;
//did u check when n=1?
//is mxN correct?
int n;
int  g[mxN][mxN];
int dp[(1<<16)],sum[(1<<16)];
void solve(int idx,int mask,int temp,vi& a,int k){
    if(idx==sz(a)){
        dp[mask]=max(dp[mask],k+sum[temp]);
        return;
    }
    solve(idx+1,mask,temp,a,k);
    solve(idx+1,mask^(1<<a[idx]),temp^(1<<a[idx]),a,k);
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>g[i][j];
        }
    }
    for(int mask=0;mask<=(1<<n)-1;mask++){
        for(int i=0;i<n;i++){
            if(!(mask & (1<<i)))continue;
            for(int j=i+1;j<n;j++){
                if((mask & (1<<j))){
                    sum[mask]+=g[i][j];
                }
            }
        }
    }
    for(int mask=0;mask<(1<<n);mask++){
        vi aux;
        for(int i=0;i<n;i++){
            if(!(mask & (1<<i)))aux.pb(i);
            solve(0,mask,0,aux,dp[mask]);
        }

    }
    cout<<dp[(1<<n)-1];
    
}
/*
	author: parv2809
*/

#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

int min(int a, int b) {
	if (a < b)
		return a;
	return b;
}

int powmd(int a, int b) {
	if (b == 1)	return a;
	if (b == 0)	return 1;

	int half = powmd(a, b / 2);
	int ans = half * half;
	ans %= mod;
	if (b & 1) {
		ans *= a;
	}
	ans %= mod;
	return ans;
}

void fastIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

int mat[16][16];
int dp[(1 << 16)], sums[(1 << 16)];

int calculate(int mask) {
	int ans = 0;
	for (int i = 0; i < 17; i++) {
		if (mask & (1 << i)) {
			for (int j = i + 1; j < 17; j++) {
				if (mask & (1 << j)) {
					ans += mat[i][j];
				}
			}
		}
	}
	return ans;
}

void pre_compute_sums() {
	for (int i = 0; i <= (1 << 16); i++) {
		sums[i] = calculate(i);
		dp[i] = inf;
	}
}

int solve(int mask) {
	if (mask == 0)
		return 0;
	if (dp[mask] != inf)
		return dp[mask];

	int s = mask;
	int ans = 0;

	while (s > 0) {
		ans = max(ans, sums[s] + solve(mask - s));
		s = (s - 1)&mask;
	}

	return dp[mask] = ans;
}

int32_t main() {

	fastIO();
	int t = 1;
	w(t) {
		int n;
		cin >> n;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> mat[i][j];
			}
		}
		pre_compute_sums();
		cout << solve((1 << n) - 1);
		nl;
	}

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;