#include using namespace std; #define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++) template bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; } template bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; } typedef long long ll; int N; const int MAX_N = 24; int edge [MAX_N] [MAX_N]; int dp [1 << MAX_N]; const int INF = 1e9; int main() { scanf("%d",&N); FOR(i,0,N) FOR(j,0,N){ scanf("%d",&edge [i] [j]); } fill(dp,dp + (1 << N),-INF); dp [0] = 0; FOR(mask,0,1 << N){ FOR(i,0,N) if((mask >> i & 1) == 0){ FOR(j,i + 1,N) if((mask >> j & 1) == 0){ int nmask = mask | (1 << i) | (1 << j); chmax(dp [nmask],dp [mask] + edge [i] [j]); } break; } } printf("%d\n",dp [(1 << N) - 1]); return 0; }