#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*M; i++){ int a; cin >> a; sum += a; if (i != 0 && i != (N*M) - 1){ minimum = min(minimum, a); } } //cout << "sum: " << sum << ", min: " << minimum << endl; if (N % 2 == 0 && M % 2 == 0){ sum -= minimum; } cout << sum << endl; return 0; }