INF = 1 << 62 N = int(input()) D = [] for i in range(N): D.append(list(map(int, input().split()))) dp = [[INF] * N for _ in range(1 << N)] dp[1 << 0][0] = 0 for i in range(1 << N): for j in range(N): if dp[i][j] == INF: continue for k in range(N): if i & (1 << k): continue ni = i | (1 << k) cost = D[j][k] * (N - i.bit_count()) dp[ni][k] = min(dp[ni][k], dp[i][j] + cost) ans = min(dp[(1 << N) - 1]) print(ans)