//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    long long H, W;
    cin >> H >> W;

    vector<vector<long long>> A(H, vector<long long>(W));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++)cin >> A[i][j];

    vector<long long> x(W);
    for (int i = 0; i < W; i++) x[i] = (i + 1) * (W - i);
    vector<long long> y(H);
    for (int i = 0; i < H; i++) y[i] = (i + 1) * (H - i);

    vector<vector<long long>> B(H, vector<long long>(W, 1));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) B[i][j] *= x[j];
    for (int i = 0; i < W; i++) for (int j = 0; j < H; j++) B[j][i] *= y[j];

    long long ans = 0;
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) ans += A[i][j] * B[i][j];

    cout << ans <<endl;

}










