#include using namespace std; typedef long long ll; template bool chmax(T& a, U b) { if (a < b) { a = b; return true; } else { return false; } } template bool chmin(T& a, U b) { if (a > b) { a = b; return true; } else { return false; } } int main() { int n; cin >> n; vector> d(n, vector(n)); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> d[i][j]; } } vector> dist((1 << n), vector(n, 1e18)); dist[1][0] = 0; dist[0][0] = 0; for (int i = 1; i < (1 << n); ++i) { bitset<16> bi(i); ll count = 0; for (int j = 0; j < n; ++j) { if (bi[j] == 0) count++; } for (int j = 0; j < n; ++j) { for (int k = 0; k < n; ++k) { if (bi[k] == 1) continue; chmin(dist[(i | (1 << k))][k], dist[i][j] + d[j][k] * count); } } } ll ans = 1e18; for (int i = 0; i < n; ++i) { chmin(ans, dist[(1 << n) - 1][i]); } cout << ans << endl; }