import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    val n = scan.nextInt()
    val a = Array(n){LongArray(n){scan.nextLong()}}
    val scores = LongArray(1.shl(n))
    for (mask in 0 until 1.shl(n)) {
        var ret = 0L
        for (i in 0 until n) {
            for (j in i+1 until n) {
                if (mask.shr(i) and 1 == 1 && mask.shr(j) and 1 == 1)
                    ret += a[i][j]
            }
        }
        scores[mask] = ret
    }

    val dp = LongArray(1.shl(n)){ (-1L).shl(60) }
    dp[0] = 0
    for (mask in 0 until 1.shl(n)) {
        for (sub in bitSubsetsOfSubset(mask)) {
            dp[mask] = Math.max(dp[mask], dp[sub] + scores[mask - sub])
        }
    }
    println(dp[1.shl(n)-1])
}

fun bitSubsetsOfSubset(sup: Int): MutableList<Int> {
    val ret = mutableListOf<Int>()
    var sub = sup
    while (true) {
        ret.add(sub)
        if (sub == 0) {
            break
        }
        sub = (sub - 1) and sup
    }
    return ret
}
