#include using namespace std; using vi = vector; void solve(){ int n, m; cin >> n >> m; int ans = 0, minimum = 1001; vector< vi > arr(n, vector(m)); for( int i = 0; i < n; ++i ){ for( int j = 0; j < m; ++j){ cin >> arr[i][j]; ans += arr[i][j]; if ( (i == 0 && j == 0) || (i == n - 1 && j == m - 1) ) continue; if (arr[i][j] < minimum ) minimum = arr[i][j]; } } if ( n % 2 == 1 || m % 2 == 1){ cout << ans << endl; return; } cout << ans - minimum << endl; return; } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int t = 1; //cin >> t; while (t--){ solve(); } return 0; }