#include <iostream> 
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <random>

using namespace std;

using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using vs = vector<string>;
using pii = pair<int, int>; using vpii = vector<pii>;
using pil = pair<int, ll>; using vpil = vector<pil>;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using pdd = pair<double, double>; using vpdd = vector<pdd>;
const int inf = (1 << 30) - 1;
const ll INF = 1LL << 60;
//const int MOD = 1000000007;
const int MOD = 998244353;

template<typename T> inline bool chmax(T& a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T& a, T b) { return ((a > b) ? (a = b, true) : (false)); }


int main() {
	int n;
	cin >> n;
	vvi f(n, vi(n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int x;
			cin >> x;
			f[i][j] = f[j][i] = x;
		}
	}

	vl dp(1 << n, -1);
	dp[0] = 0;

	for (int b = 0; b < (1 << n) - 1; b++) {
		if (dp[b] == -1) continue;
		int x = -1;
		for (int i = 0; i < n; i++) {
			if ((b & (1 << i)) == 0) {
				x = i;
				break;
			}
		}
		for (int i = 0; i < n; i++) {
			if ((b & (1 << i)) == 0) {
				int to = b | (1 << x) | (1 << i);
				chmax(dp[to], dp[b] + f[x][i]);
			}
		}
	}

	cout << dp[(1 << n) - 1] << endl;


	return 0;
}