#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;
}
