#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 == 0 && j == 0) || (i == N-1 && j == M-1)) { continue; } if(mn == -1) { mn = v; } else { mn = min(mn,v); } } } if(M % 2 == 1 || N % 2 == 1) { cout << sum << "\n"; return 0; } sum -= mn; cout << sum << "\n"; }