#include #include #include using namespace std; int main(){ int N, M; cin >> N >> M; int sum = 0; int mn = -1; for(int i = 0; i < N; i++) { for(int j = 0; j < M; j++) { int v; cin >> v; sum += v; if((i == N-1 && j == M-2) || (j == M-1 && i == N-2)) { if(mn == -1) mn = v; else mn = min(mn,v); } } } if(M % 2 == 1 || M % 2 == 1) { cout << sum; return sum; } sum -= mn; cout << sum; return sum; }