//#define LOCAL #include #include #include #include #include #include #include #include #define int long long //typedef long long ll; #define rep(i, n) for(int i=0; i<(n); i++) using namespace std; int n; int F[30][30]; int dp[1 << 25]; int rec(int S) { if (dp[S] != -1) return dp[S]; if (S == 0) return 0; int mx = -1; for (int i=0; i<(n-1); i++) { for (int j=i+1; j> i & 1) && (S >> j & 1)) { int tempS = S; tempS = tempS & ~(1 << i); tempS = tempS & ~(1 << j); mx = max(mx, rec(tempS) + F[i][j]); } } } return dp[S] = mx; } signed main() { #ifdef LOCAL ifstream in("input.txt"); cin.rdbuf(in.rdbuf()); #endif cin >> n; rep(i, n) rep(j, n) { cin >> F[i][j]; } rep(i,(1<<(n-1))) { dp[i] = -1; } cout << rec((1 << n) - 1) << endl; }