#include using namespace std; const int N = 26; const int S = N - 2; const int E = N - 1; const int INF = 1000000000; int n, m; int c[N][N] = { 0, }; int d[N][N] = { 0, }; int f[N][N] = { 0, }; vector adj[N]; int board[25][25]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n,m; cin >> m; for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { cin >> board[i][j]; } } n = m / 2; vector perm(m, 0); for (int i = 0; i < n; i++) { perm[i] = 1; } sort(perm.begin(), perm.end()); int ret = 0; do { memset(c, 0, sizeof(c)); memset(d, 0, sizeof(d)); for (int i = 0; i < N; i++) { adj[i].clear(); } vector a, b; for (int i = 0; i < m; i++) { if (perm[i] == 0) { a.push_back(i); } else { b.push_back(i); } } for (int i = 0;i que; memset(prev, -1, sizeof(prev)); for (int i = 0; i < N; i++) { dist[i] = 1e9; } que.push(S); dist[S] = 0; inqueue[S] = true; while (!que.empty()) { int now = que.front(); que.pop(); inqueue[now] = false; for (auto next : adj[now]) { //cout << now << ' ' << next << ' ' << c[now][next] << ' ' << f[now][next] << ' ' << dist[now] << ' ' << dist[next] << ' ' << d[now][next] << '\n'; if (c[now][next] - f[now][next] > 0 && dist[next] > dist[now] + d[now][next]) { dist[next] = dist[now] + d[now][next]; prev[next] = now; if (!inqueue[next]) { que.push(next); inqueue[next] = true; } } } } if (prev[E] == -1) { break; } for (int i = E; i != S; i = prev[i]) { res += d[prev[i]][i]; f[prev[i]][i]++; f[i][prev[i]]--; } cnt++; } ret = max(ret, abs(res)); } while (next_permutation(perm.begin(), perm.end())); cout << ret << '\n'; return 0; }