#include #include #include #include using namespace std; int main(){ int N, M; cin >> N >> M; int minimum = INT32_MAX; int sum = 0; for (int i = 0; i < N; i++){ for(int j = 0; j < M; j++){ int a; cin >> a; sum += a; if((i == 0 && j == 0) || (i == N-1 && j == M-1) || (i == j) || (i + (M-N) == j) ){ continue; } else{ minimum = min(minimum, a); } } } //cout << "sum: " << sum << ", min: " << minimum << endl; if (N % 2 == 0 && M % 2 == 0){ sum -= minimum; } cout << sum << endl; return 0; }