#include int main() { int lines, columns; std::cin >> lines; std::cin >> columns; bool twoEvens = ((lines % 2 == 0) && (columns % 2 == 0)); long long sum = 0; long long min = -1; for (int i = 0; i < lines; i++) { for (int j = 0; j < columns; j++) { long long currentNum; std::cin >> currentNum; sum = sum + currentNum; bool isStart = ((i == 0) && (j == 0)); bool isEnd = ((i == lines - 1) && (j == columns - 1)); if ((!isStart) && (!isEnd) && ((min == -1) || (min > currentNum))) { min = currentNum; } } } std::cout << sum - (twoEvens ? min : 0); return 0; }