// // Created by cteam37 on 10/19/24. // #include #include using namespace std; int main() { int n,m; cin >> n; cin >> m; ::uint64_t totalSum = 0; int min = INT32_MAX; for (int row = 0; row < n; ++row) { for (int col = 0; col < m; ++col) { int val; cin >> val; totalSum += val; if(row == col) { continue; } if (val < min) min = val; } } if(n%2 == 0 && m%2 == 0) { cout << totalSum - min << endl; } else { cout << totalSum << endl; } return 0; }