#include using namespace std; int board[25][25]; int dp[1 << 24]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> board[i][j]; } } memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 0; i < (1 << n); i++) { if (dp[i] == -1) continue; vector v; for (int j = 0; j < n; j++) { if ((i & (1 << j))) continue; v.push_back(j); } for (int j = 0; j < v.size(); j++) { for (int k = j+1; k < v.size(); k++) { if (j == k) continue; int mask = i + (1 << v[j]) + (1 << v[k]); dp[mask] = max(dp[mask], dp[i] + board[v[j]][v[k]]); } } } cout << dp[(1 << n) - 1] << '\n'; return 0; }