def solve(): def rec(s, memo={0: 0}): if not s in memo: i = (s & -s).bit_length() - 1 u = t = s & (s - 1) best = 0 while t: f = t & -t j = f.bit_length() - 1 best = max(best, rec(u ^ f) + cost[i][j]) t ^= f memo[s] = best return memo[s] N = int(raw_input()) cost = [list(map(int, raw_input().split())) for _ in range(N)] print(rec(2 ** N - 1)) solve()