// Original C++ solution (slower):
#include <bits/stdc++.h>

#define f first

#define s second

#define pb push_back

#define ENDL '\n'

#define all(a) begin(a), end(a)

#define sz(a) (int)(a.size())

#define deb(a) cout << #a << ": " << a << ENDL

#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)

#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);



using namespace std;



typedef long long lli;

typedef long double ld;

typedef pair<lli, lli> ii;

typedef vector<lli> vi;



const int MAXN = 16;

const int MAX = (1 << MAXN);

lli INF = 1e18;



lli dp[MAX];

lli calc[MAX];



lli n;



bool cmp(lli u, lli v) {

    return __builtin_popcount(u) < __builtin_popcount(v);

}



lli solve(lli mask) {

    lli &ans = dp[mask];

    if(ans != -1) return ans;

    ans = calc[mask];

    vi pos;

    fore(i, 0, 16) if(mask & (1 << i)) pos.pb(i);

    int cnt = sz(pos);

    fore(i, 1, (1 << cnt) - 1) {

        lli nwMask = 0;

        fore(j, 0, cnt) if(i & (1 << j)) nwMask |= (1 << pos[j]);

        ans = max(ans, solve(nwMask) + solve(mask ^ nwMask));

    }

    return ans;

}



int main()

{   _

    cin >> n;

    fore(i, 0, MAX) dp[i] = -1;

    vector<vector<lli>> mat(n, vector<lli>(n));

    fore(i, 0, n) fore(j, 0, n) cin >> mat[i][j];

    vector<lli> state((1 << n));

    fore(i, 0, (1 << n)) state[i] = i;

    sort(all(state), cmp);

    calc[0] = 0;

    fore(i, 1, (1 << n)) {

        fore(j, 0, n) {

            if(state[i] & (1 << j)) {

               calc[state[i]] += calc[state[i] ^ (1 << j)];

               fore(k, 0, n) {

                    if(k == j or (!(state[i] & (1 << k)))) continue;

                    calc[state[i]] += mat[j][k];

               }

               break;

            }

        }

    }

    cout << solve((1 << n) - 1) << ENDL;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimization ("O3")

#pragma GCC optimization ("unroll-loops")

#define db "BSF"

#define fi first

#define se second

#define endl '\n'

#define int long long

const int INF = 1e15 + 1;

const int mod = 1e9 + 7;

typedef long long ll;

typedef pair<int, int> PII;

typedef pair<PII, int> PII2;

typedef pair<int, PII> PII3;

typedef pair<PII, PII> PII4;



void docfile()

{

    if (ifstream("FORM.inp"))

    {

        freopen("FORM.inp", "r", stdin);

        freopen("FORM.out", "w", stdout);

    }

    else if (ifstream(db".inp"))

    {

        freopen(db".inp", "r", stdin);

        freopen(db".out", "w", stdout);

    }

}



//---------------------------------------------------------------------------

const int N = 16 + 5;

int n, a[N][N];

int dp[100000];

int p[100000];



void input()

{

    cin >> n;

    for(int i = 1; i <= n; i++)

    for(int j = 1; j <= n; j++)

    cin >> a[i][j];

}



void solve()

{

    int m = (1<<n);

    for(int mask = 0; mask < m; mask++)

    {

        vector <int> v;

        for(int i = 0; i < n; i++)

        {

            if(((1<<i)&mask) != 0) v.push_back(i+1);

        }

        for(int i = 0; i < v.size(); i++)

        for(int j = i + 1; j < v.size(); j++)

        dp[mask] += a[v[i]][v[j]];

    }

    for(int mask = 0; mask < m; mask++)

    {

        for(int i = mask; i; i = (i-1)&mask)

        {

            dp[mask] = max(dp[mask], dp[i] + dp[mask^i]);

        }

    }

    cout << dp[m-1];

}



int32_t main()

{

    docfile();

    ios_base::sync_with_stdio(false);

    cin.tie(0); cout.tie(0);



    //int test = 1; cin >> test; while(test--) {input(); solve();}

    input(); solve();

}





//-----------------------------------------------------------------------------



/*

int read()

{

    int x = 0, f = 1;

    char c = getchar();

    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}

    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}

    return x * f;

}

void write(int x)

{

    if (x > 9) write(x / 10);

    putchar(x % 10 + '0');

}

*/


// Fastest known solution for this problem:
#include <iostream>

#include <algorithm>

#include <vector>

#include <cassert>



using namespace std;





int main() {



  int N;



  cin >> N;

  vector< vector<long long> > A(N, vector<long long>(N));



  for (auto i=0;i <N; i++)

  for (auto j=0;j <N; j++) cin >> A[i][j];



  vector<long long> F( 1<<17, 0);



  // consider all sub sets of {1..N}

  vector<int> l(16, 0);

  for (long long s = 1; s < (1<<N); s++) {

    l.resize(0);



    auto ss= s;

    int c = 0;

    while(ss != 0) {

      if (ss & 1 ) l.push_back(c);

      ss = ss >> 1;

      c++;

    }



    // for (auto tt=0; tt<l.size(); tt++) 

    // cout << "l" << l[tt] << "  ";

    // cout << endl;

    F[s] = 0;

    for (auto i=0; i < l.size(); i++)

    for (auto j=i+1; j < l.size(); j++) F[s] += A[l[i]][l[j]];



    auto L = l.size();



    for (int j = s; j; j = (j-1)&s) {

      F[s] = max( F[s], F[s^j]+F[j]);

    }



    // cout << endl;

  }





  cout << F[ (1<<N)-1] << endl;



  return 0;

}