let N = Int(readLine()!)!

var a = [[Int]]()
for _ in stride(from: 0, to: N, by: 1) {
    let row = readLine()!.split(separator: " ").map { Int($0)! }
    a.append(row)
}

/// arrayOfScore[combination] = score
/// うさぎのうちのcombinationがグループになっている時に得られる得点score
var arrayOfScore = [Int]()
for combination in stride(from: 0, to: 1 << N, by: 1) {
    var score = 0
    for i in stride(from: 0, to: N, by: 1) {
        for j in stride(from: i + 1, to: N, by: 1) {
            if (combination >> i) & 1 == 1, (combination >> j) & 1 == 1 {
                score += a[i][j]
            }
        }
    }
    arrayOfScore.append(score)
}

/// dp[combination] = score
/// うさぎのうちのcombinationがどこかしらに所属している時の得点score
var dp = Array(repeating: 0, count: 1 << N)
for combination in stride(from: 0, to: 1 << N, by: 1) {
    /// 未所属のうさぎ
    let rabbitsNotBelonging = combination ^ (1 << N - 1)
    var subset = rabbitsNotBelonging
    /// 未所属うさぎ集団の全ての部分集合について
    while subset > 0 {
        let nextCombination = subset | combination
        dp[nextCombination] = max(dp[nextCombination], dp[combination] + arrayOfScore[subset])
        subset = (subset - 1) & rabbitsNotBelonging
    }
}

print(dp[1 << N - 1])
