import sys
readline = sys.stdin.readline
from collections import Counter

def popcount(i):
    assert 0 <= i < 0x100000000
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24

INF = 10**18
N = int(readline())
A = [list(map(int, readline().split())) for _ in range(N)]

dp = Counter()
dp[0] = -INF
for i in range(N):
    dpnew = Counter()
    for k, v in dp.items():
        if popcount(k) <= N-i-2:
            dpnew[k|(1<<i)] = max(dpnew[k|(1<<i)], dp[k])
        for j in range(N):
            if (1<<j) & k:
                key = k^(1<<j)
                dpnew[key] = max(dpnew[key], dp[k] + A[i][j])
    dp = dpnew.copy()
print(dp[0])