#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,x,n) for(int i = x;i <= n;++i)	
#define Angel_Dust ios::sync_with_stdio(0);cin.tie(0)

const int N = 3e5+7;
ll sum[N],ssum[N],a[N];

int main() 
{
	Angel_Dust;
	int n;cin >> n;
	forn(i,1,n)	cin >> a[i];
	forn(i,1,n)	sum[i] = sum[i - 1] + a[i],ssum[i] = ssum[i - 1] + a[i] * a[i];
	
	ll res = 0;
	forn(i,2,n)
	{
		res += (i - 1) * (a[i] * a[i]);
		res += ssum[i - 1];
		res -= 2 * a[i] * sum[i - 1];
	}
	printf("%lld\n",res);
	return 0;
}
#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define lowbit(x) ((x) & -(x))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr double eps = 1e-8;
constexpr int NINF = 0xc0c0c0c0;
constexpr int INF = 0x3f3f3f3f;
constexpr ll mod = 1e9 + 7;
constexpr ll N = 1e6 + 5;

int dx[] = {1, 1, 0, 0};
int dy[] = {0, 1, 1, 0};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++) cin >> s[i];
    int ans = 0;
    for (int i = 0; i + 1 < H; i++) {
        for (int j = 0; j + 1 < W; j++) {
            int cnt = 0;
            for (int k = 0; k < 4; k++) {
                cnt += s[i + dx[k]][j + dy[k]] == '#';
            }
            ans += cnt & 1;
        }
    }
    cout << ans << '\n';

    return 0;
}