#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int N;
	cin >> N;
	vector<vector<ll>> a(N, vector<ll>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}
	vector<ll> cost(1 << N);
	for (int i = 1; i < (1 << N); i++) {
		for (int k = 0; k < N; k++) if (i & (1 << k)) {
			for (int l = k + 1; l < N; l++) if (i & (1 << l)) {
				cost[i] += a[k][l];
			}
		}
	}
	vector<ll> dp(1 << N);
	for (int i = 1; i < (1 << N); i++) {
		for (int j = i;; j = (j - 1) & i) {
			dp[i] = max(dp[i], dp[j] + cost[i - j]);
			if (j == 0) break;
		}
	}
	cout << dp.back() << endl;
	return 0;
}
