#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,f[2000006],a[22][22];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen("QUEUE.inp", "r", stdin);
freopen("QUEUE.out", "w", stdout);
cin >> n;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
{
cin >> a[i][j];
}
memset(f, -0x3f, sizeof f);
ll tt = (1<<n)-1;
f[0] = 0;
for(int i = 0; i < tt; i++)
{
ll d = __builtin_popcount(i);
for(int j = 0; j < n; j++)
{
if(!((i>>j)&1))
{
ll p = i | (1<<j);
f[p] = max(f[p],f[i] + a[j][d]);
}
}
}
cout << f[tt];
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbGwgbixmWzIwMDAwMDZdLGFbMjJdWzIyXTsKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOyBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKICAgIGZyZW9wZW4oIlFVRVVFLmlucCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3BlbigiUVVFVUUub3V0IiwgInciLCBzdGRvdXQpOwogICAgY2luID4+IG47CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBuOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBjaW4gPj4gYVtpXVtqXTsKICAgICAgICB9CiAgICBtZW1zZXQoZiwgLTB4M2YsIHNpemVvZiBmKTsKICAgIGxsIHR0ID0gKDE8PG4pLTE7CiAgICBmWzBdID0gMDsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCB0dDsgaSsrKQogICAgewogICAgICAgIGxsIGQgPSBfX2J1aWx0aW5fcG9wY291bnQoaSk7CiAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IG47IGorKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKCEoKGk+PmopJjEpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBsbCBwID0gaSB8ICgxPDxqKTsKICAgICAgICAgICAgICAgIGZbcF0gPSBtYXgoZltwXSxmW2ldICsgYVtqXVtkXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IGZbdHRdOwp9Cg==