#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector f(n, vi(n)); rep(i, n)rep(j, n)cin >> f[i][j]; vi dp(1 << n, -1); dp[0] = 0; rep(S, (1 << n) - 1) if (dp[S] != -1) { int k = 0; rep(i, n)if (!(S >> i & 1)) { k = i; break; } int nS = S | 1 << k; FOR(i, k + 1, n) if (!(S >> i & 1)) { smax(dp[nS | 1 << i], dp[S] + f[i][k]); } } cout << dp.back() << endl; }