//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>

using namespace std;
//using namesparsace __gnu_pbds;

void solve();

int main() {
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

#define ld double
#define int long long

const int maxN = 3e3 + 10, maxK = 1e5 + 10, inf = 1e15 + 10, mod = 1e9 + 7, base = 223;

int n, a[16][16], cost[1 << 16], dp[1 << 16];

bool bit(int a, int i) {
    return (a >> i) & 1;
}

int get(int mask) {
    vector < int > v;
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (bit(mask, i)) {
            for (int j = 0; j < v.size(); j++) {
                res += a[v[j]][i];
            }
            v.push_back(i);
        }
    }
    return res;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i < (1 << n); i++) {
        cost[i] = get(i);
    }
    for (int mask = 1; mask < (1 << n); mask++) {
        int submask = mask;
        while (submask > 0) {
            dp[mask] = max(dp[mask], dp[mask ^ submask] + cost[submask]);
            submask = mask & (submask - 1);
        }
    }
    cout << dp[(1 << n) - 1];
}

// submask = mask & (mask - 1);
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#define MOD(x) (x + 1000000007) % (1000000007)

using namespace std;

template <class t>
using vec = vector<t>;
using ll = long long;

const int MAX = numeric_limits<int>::max();

template <class t>
ostream &operator<<(ostream &out, vec<t> &v)
{
    for (auto &e : v)
        out << e << " ";
    out << "\n";
    return out;
}

template <class t>
istream &operator>>(istream &in, vec<t> &v)
{
    for (auto &e : v)
        in >> e;
    return in;
}

int n;
vec<vec<ll>> a;
vec<ll> dp, pre;

void find(ll used, vec<int> &not_used, ll group_mask, int index)
{
    if (index == not_used.size())
    {
        dp[used | group_mask] = max(dp[used | group_mask], dp[used] + pre[group_mask]);
        return; 
    }
    find(used, not_used, group_mask, index + 1);
    find(used, not_used, group_mask | (1 << not_used[index]), index + 1);
}

int main()
{
    cin >> n;
    a = vec<vec<ll>>(n, vec<ll>(n));
    cin >> a;
    dp = vec<ll>(1 << n);
    pre = vec<ll>(1 << n);
    for (ll mask = 0; mask < (1 << n); mask++)
        for (int i = 0; i < n; i++)
            if (mask & (1 << i))
                for (int j = i + 1; j < n; j++)
                    if (mask & (1 << j))
                        pre[mask] += a[i][j];
    for (ll mask = 0; mask < (1 << n); mask++)
    {
        vec<int> not_used;
        for (int i = 0; i < n; i++)
            if (!(mask & (1 << i))) not_used.push_back(i);
        find(mask, not_used, 0, 0);
    }
    cout << dp[(1 << n) - 1];
    return 0;
}