#include <bits/stdc++.h>

#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair

const int inf = 0x3f3f3f3f ;
const int MAXN = 18 ;

using namespace std ;

bool isOn(int m , int bit) { return ( (m&(1<<bit)) != 0 ); }

int n ;
ll dp[(1<<MAXN)] , mat[MAXN][MAXN] , s[ (1<<MAXN) ] ;

int main()
{
	scanf("%d", &n) ;
	lp(i,0,n)
		lp(j,0,n) 
			scanf("%lld", &mat[i][j]) ;
	lp(m,1,(1<<n))
		lp(i,0,n)
			lp(j,i+1,n)
				if( isOn(m,i) && isOn(m,j) )
					s[m] += mat[i][j] ;
	
	lp(m,1,(1<<n))
		for(int sub = m ; sub > 0 ; sub= ((sub-1)&m) )
			dp[m] = max(dp[ ( m&(~sub) ) ] + s[sub] , dp[m]) ;
	printf("%lld\n" , dp[(1<<n)-1]) ;
}
