using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3");
WillReturn.Add("0 10 20");
WillReturn.Add("10 0 -100");
WillReturn.Add("20 -100 0");
//20
}
else if (InputPattern == "Input2") {
WillReturn.Add("2");
WillReturn.Add("0 -10");
WillReturn.Add("-10 0");
//0
}
else if (InputPattern == "Input3") {
WillReturn.Add("4");
WillReturn.Add("0 1000000000 1000000000 1000000000");
WillReturn.Add("1000000000 0 1000000000 1000000000");
WillReturn.Add("1000000000 1000000000 0 -1");
WillReturn.Add("1000000000 1000000000 -1 0");
//4999999999
}
else if (InputPattern == "Input4") {
WillReturn.Add("16");
WillReturn.Add("0 5 -4 -5 -8 -4 7 2 -4 0 7 0 2 -3 7 7");
WillReturn.Add("5 0 8 -9 3 5 2 -7 2 -7 0 -1 -4 1 -1 9");
WillReturn.Add("-4 8 0 -9 8 9 3 1 4 9 6 6 -6 1 8 9");
WillReturn.Add("-5 -9 -9 0 -7 6 4 -1 9 -3 -5 0 1 2 -4 1");
WillReturn.Add("-8 3 8 -7 0 -5 -9 9 1 -9 -6 -3 -8 3 4 3");
WillReturn.Add("-4 5 9 6 -5 0 -6 1 -2 2 0 -5 -2 3 1 2");
WillReturn.Add("7 2 3 4 -9 -6 0 -2 -2 -9 -3 9 -2 9 2 -5");
WillReturn.Add("2 -7 1 -1 9 1 -2 0 -6 0 -6 6 4 -1 -7 8");
WillReturn.Add("-4 2 4 9 1 -2 -2 -6 0 8 -6 -2 -4 8 7 7");
WillReturn.Add("0 -7 9 -3 -9 2 -9 0 8 0 0 1 -3 3 -6 -6");
WillReturn.Add("7 0 6 -5 -6 0 -3 -6 -6 0 0 5 7 -1 -5 3");
WillReturn.Add("0 -1 6 0 -3 -5 9 6 -2 1 5 0 -2 7 -8 0");
WillReturn.Add("2 -4 -6 1 -8 -2 -2 4 -4 -3 7 -2 0 -9 7 1");
WillReturn.Add("-3 1 1 2 3 3 9 -1 8 3 -1 7 -9 0 -6 -8");
WillReturn.Add("7 -1 8 -4 4 1 2 -7 7 -6 -5 -8 7 -6 0 -9");
WillReturn.Add("7 9 9 1 3 2 -5 8 7 -6 3 0 1 -8 -9 0");
//132
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int N = int.Parse(InputList[0]);
int[,] ScoreArr = CreateBanArr(InputList.Skip(1));
int AllBitON = (1 << N) - 1;
// 1グループのスコア[該当グループのBitSet]
long[] ScoreSumArr = new long[AllBitON + 1];
for (int I = 0; I <= AllBitON; I++) {
long ScoreSum = 0;
for (int J = 0; J <= N - 1; J++) {
for (int K = J + 1; K <= N - 1; K++) {
int Bit1 = 1 << J;
int Bit2 = 1 << K;
if ((Bit1 & I) == 0) continue;
if ((Bit2 & I) == 0) continue;
ScoreSum += ScoreArr[J, K];
}
}
ScoreSumArr[I] = ScoreSum;
}
// 最大スコア[使用済のBitSet]
long[] DPArr = new long[AllBitON + 1];
for (int I = 0; I <= AllBitON; I++) {
foreach (int EachSubSet in DeriveEnumSubSet(I)) {
DPArr[I] = Math.Max(DPArr[I], ScoreSumArr[EachSubSet] + DPArr[I - EachSubSet]);
}
}
Console.WriteLine(DPArr[AllBitON]);
}
// 引数のBitSetの部分集合の列挙を返す
static IEnumerable<int> DeriveEnumSubSet(int pBase)
{
int pCurr = pBase;
while (true) {
yield return pCurr;
if (pCurr == 0) break;
pCurr = (pCurr - 1) & pBase;
}
}
////////////////////////////////////////////////////////////////
// IEnumerable<string>をintの2次元配列に設定する
////////////////////////////////////////////////////////////////
static int[,] CreateBanArr(IEnumerable<string> pStrEnum)
{
var StrList = pStrEnum.ToList();
if (StrList.Count == 0) {
return new int[0, 0];
}
int[] IntArr = { };
Action<string> SplitAct = pStr =>
IntArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray();
SplitAct(StrList[0]);
int UB_X = IntArr.GetUpperBound(0);
int UB_Y = StrList.Count - 1;
int[,] WillReturn = new int[UB_X + 1, UB_Y + 1];
for (int Y = 0; Y <= UB_Y; Y++) {
SplitAct(StrList[Y]);
for (int X = 0; X <= UB_X; X++) {
WillReturn[X, Y] = IntArr[X];
}
}
return WillReturn;
}
}