#include <bits/stdc++.h>

using namespace std;

int n;
int f[24][24];
int dp[1 << 24];

int solve(int used) {
	if (used == (1 << n) - 1) return 0;
	if (dp[used] != 0) return dp[used];
	int res = 0;
	int cur = 0;
	for (int i = 0; i < n; i++) {
		if (used & (1 << i)) continue;
		cur = i;
		break;
	}
	for (int i = cur + 1; i < n; i++) {
		if (used & (1 << i)) continue;
		int nex = used;
		nex |= (1 << cur);
		nex |= (1 << i);
		res = max(res, solve(nex) + f[cur][i]);
	}
	return dp[used] = res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> f[i][j];
		}
	}
	cout << solve(0) << endl;
	return 0;
}