// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 1.4846983094688153x):
#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');

}

*/