l=[*map(int,open(0).read().split())]
n=l[0];o=l[1:];print(sum(o)-min(o[n-1:-1:n-1]))
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
const int INF = numeric_limits<int>::max();
const int nax = (int)(590001);
const int mod = 1e9 + 7;
template<class X, class Y>
bool maximize(X& x, const Y y) {
if (y > x) {x = y; return true;}
return false;
}
template<class X, class Y>
bool minimize(X& x, const Y y) {
if (y < x) {x = y; return true;}
return false;
}
int nxt() {
int x; cin >> x;
return x;
}
#define Fi first
#define Se second
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
void solve() {
int n; cin >> n;
vvi grid(n, vi(n));
int sum = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
cin >> grid[i][j];
sum += grid[i][j];
}
}
int mini = INT_MAX;
// for(int i = 0; i < n - 1; i++) {
// mini = min(mini, grid[i][i + 1]);
// }
for(int i = 0; i < n; i++) {
mini = min(mini, grid[i][n - i - 1]);
}
cout << (sum - mini) << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
// code here
solve();
return 0;
}
842B - Gleb And Pizza | 1746D - Paths on the Tree |
1651E - Sum of Matchings | 19A - World Football Cup |
630P - Area of a Star | 1030C - Vasya and Golden Ticket |
1529D - Kavi on Pairing Duty | 1743A - Password |
1743B - Permutation Value | 1743C - Save the Magazines |
1743D - Problem with Random Tests | 1070K - Video Posts |
767C - Garland | 1201B - Zero Array |
1584C - Two Arrays | 1131C - Birthday |
1285B - Just Eat It | 1743F - Intersection and Union |
771A - Bear and Friendship Condition | 1208E - Let Them Slide |
656A - Da Vinci Powers | 1025A - Doggo Recoloring |
257A - Sockets | 231C - To Add or Not to Add |
1454E - Number of Simple Paths | 931B - World Cup |
934B - A Prosperous Lot | 999B - Reversing Encryption |
1238D - AB-string | 810B - Summer sell-off |