n = int(input()) F = [list(map(int,input().split())) for _ in range(n)] dp = [1] * (1 << n) dp[0] = 0 for bit in range(1 << n): if dp[bit] < 0:continue i = 0 while bit >> i & 1:i += 1 b = bit | (1 <> j & 1:continue bj = b | (1 << j) if dp[bj] < dp[bit] + F[i][j]: dp[bj] = dp[bit] + F[i][j] print(dp[-1])