#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
/*
x = kx + y + z + o;
x = ky+kz+k2x;
x = y(1+k+k2+k3+k4.......)+z(1+k+k2+k3+k4+k5.........)+o(1+k+k2+k3+k4+k5.........)
x = (y+z+o)*(1/(1-k));
*/
int n;
ll dp[1<<17];
ll val[1<<17];
ll f(ll msk){
       if(msk == (1<<n)-1){
              return 0;
       }
       if(dp[msk] != -1){
              return dp[msk];
       }
       vector<int> ind;
       fri(i,0,n){
              if((msk & (1LL<<i))==0){
                     ind.pb(i);
              }
       }
       int nn = ind.size();
       dp[msk] = -inf;
       fri(i,0,(1LL<<nn)){
              int tmsk = msk;
              fri(j,0,nn){
                     if(i&(1LL<<j)){
                            tmsk |= (1LL<<ind[j]);
                     }
              }
              dp[msk] = max(dp[msk],val[tmsk^msk]+f(tmsk));
       }
       return dp[msk];
}
int main()
{
       memset(dp,-1,sizeof dp);
       cin>>n;
       ll mat[n][n];
       fri(i,0,n){
              fri(j,0,n){
                     cin>>mat[i][j];
              }
       }
       fri(i,0,1<<n){
              val[i] = 0;
              fri(j,0,n){
                     fri(k,j+1,n){
                            if(i&(1LL<<j) && (i&(1LL<<k))){
                                   val[i] += mat[j][k];
                            }
                     }
              }
       }
       cout<<f(0)<<endl;
}


Measured memory_bytes: 1792