#include<bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
usingnamespacestd;typedeflonglongll;lln,g[1515][1515];lldp[1515][1515];llf(ints,inte,intx){ll&res=dp[s][e];if(res!=-1)returnres;if(x>n)returnres=0;llt1=f(x,e,x+1)+g[x][s];llt2=f(s,x,x+1)+g[e][x];returnres=min(t1,t2);}intmain(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cin>>n;for(inti=1;i<=n;i++)for(intj=1;j<=n;j++)cin>>g[i][j];memset(dp,-1,sizeofdp);cout<<f(1,1,1);}