N = int(input()) C = tuple(tuple(map(int, input().split())) for _ in range(N)) INF = 10 ** 18 dp = [[INF] * (3 ** N) for _ in range(N)] for i in range(N): dp[i][3 ** i] = 0 for b in range(3 ** N): for i in range(N): flag_i = (b // (3 ** i)) % 3 if flag_i == 0: continue for j in range(N): flag_j = (b // (3 ** j)) % 3 if flag_j == 0: dp[j][b + 3 ** j] = min(dp[j][b + 3 ** j], dp[i][b] + C[i][j]) elif flag_j == 1 and i != j: dp[j][b + 3 ** j] = min(dp[j][b + 3 ** j], dp[i][b] + C[i][j]) ans = INF # 全部2回 for i in range(N): ans = min(ans, dp[i][3 ** N - 1]) # 最後の1個以外全部2回 for i in range(N): b = 0 for j in range(N): if j == i: b += 3 ** j else: b += 2 * 3 ** j ans = min(ans, dp[i][b]) print(ans)