#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
const int nmax = 210;
const int inf = 0x3f3f3f3f;
struct Edge {
int u, v, cap, flow, cost;
Edge(int _u, int _v, int _cap, int _flow, int _cost) {
u = _u;
v = _v;
cap = _cap;
flow = _flow;
cost = _cost;
}
};
vector<Edge> E;
vector<int> g[nmax];
int n, cost[nmax][nmax], source, sink;
int father[nmax], dist[nmax];
bool inqueue[nmax];
bool bellmanford() {
for (int i = source; i <= sink; ++ i) {
inqueue[i] = 0;
father[i] = -1;
dist[i] = inf;
}
queue<int> q;
q.push(source);
dist[source] = 0;
while (!q.empty()) {
int node = q.front();
q.pop();
inqueue[node] = 0;
for (int ind : g[node]) {
Edge e = E[ind];
if (e.cap > e.flow && dist[e.u] + e.cost < dist[e.v]) {
dist[e.v] = dist[e.u] + e.cost;
father[e.v] = ind;
if (!inqueue[e.v]) {
inqueue[e.v] = 1;
q.push(e.v);
}
}
}
}
return dist[sink] != inf;
}
void maxflow() {
int ans = 0;
while (bellmanford()) {
int minflow = inf, node = sink;
while (node != source) {
Edge e = E[father[node]];
minflow = min(minflow, e.cap - e.flow);
node = e.u;
}
node = sink;
while (node != source) {
Edge &e = E[father[node]];
Edge &re = E[father[node] ^ 1];
e.flow += minflow;
re.flow -= minflow;
node = e.u;
}
ans += dist[sink] * minflow;
}
printf("%d\n", ans);
}
int main()
{
freopen("cc.in", "r", stdin);
freopen("cc.out", "w", stdout);
scanf("%i", &n);
source = 0;
sink = 2 * n + 1;
for (int i = 1; i <= n; ++ i) {
for (int j = 1; j <= n; ++ j) {
scanf("%i", &cost[i][j]);
E.push_back(Edge(i, j + n, 1, 0, cost[i][j]));
g[i].push_back(E.size() - 1);
E.push_back(Edge(j + n, i, 0, 0, -cost[i][j]));
g[j + n].push_back(E.size() - 1);
}
}
for (int i = 1; i <= n; ++ i) {
E.push_back(Edge(source, i, 1, 0, 0));
g[source].push_back(E.size() - 1);
E.push_back(Edge(i, source, 0, 0, 0));
g[i].push_back(E.size() - 1);
E.push_back(Edge(i + n, sink, 1, 0, 0));
g[i + n].push_back(E.size() - 1);
E.push_back(Edge(sink, i + n, 0, 0, 0));
g[sink].push_back(E.size() - 1);
}
maxflow();
return 0;
}