#include<bits/stdc++.h>
using namespace std;
#define int 		long long
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			push_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ll)16e-9
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl; }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define re 			resize
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a <<"   ";
	err(++it, args...);
}
string to_string(string s) {
	return '"' + s + '"';
}
string to_string(const char* s) {
	return to_string((string) s);
}
string to_string(bool b) {
	return (b ? "true" : "false");
}
string to_string(char ch) {
	return string("'")+ch+string("'");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <class InputIterator>
string to_string (InputIterator first, InputIterator last) {
	bool start = true;
	string res = "{";
	while (first!=last) {
		if (!start) {
			res += ", ";
		}
		start = false;
		res += to_string(*first);
		++first;
	}
	res += "}";
	return res;
}
template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}
template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}
int n;
int a[16][16];
int ma[1<<16],dp[1<<16];
bool vis[1<<16];
void fill(int mask)
{	
	if(vis[mask]) 
		return ;
	vis[mask]=1;
	rep(i,0,n)
	{
		if(mask&(1<<i)) continue;
		ma[mask|(1<<i)]=ma[mask];
		rep(j,0,n)
		if(mask&(1<<j))
			ma[mask|(1<<i)]+=a[i][j];
		fill(mask|(1<<i));
	}
}
void solve(int mask)
{
	if(!vis[mask])
		return;
	vis[mask]=0;
	if(mask==((1<<n)-1))
	{
		dp[mask]=0;
		return;
	}
	int x=((1<<n)-1)-mask;
	dp[mask]=ma[x];
	for(int i=x;i;i=(i-1)&x)
	{
		solve(i|mask);
		dp[mask]=max(dp[mask],ma[i]+dp[i|mask]);
	}
}
signed main(void)
{ios
    cin>>n;
    rep(i,0,n)
    rep(j,0,n)
    cin>>a[i][j];
   	fill(0);
   	solve(0);
   	cout<<dp[0]<<endl;
}

Measured memory_bytes: 1408