#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	unsigned long long n, m, a = 0;
	cin >> n >> m;
	int k[n];
	for(int i = 0; i < n; i++){
		long long a;
		cin >> a;
		if(a % 2 == 0){
			k[i] = 1;
		}else{
			k[i] = 0;
		}
	}
	long long t[n], f[n];
	for(int i = n - 1; i >= 0; i--){
		t[i] = 0;
		f[i] = 0;
		if(k[i] == 1 && i < n - 1){
			t[i] += t[i + 1] + 1;
			f[i] = f[i + 1];
		}else if(k[i] == 0 && i < n - 1){
			f[i] += f[i + 1] + 1;
			t[i] = t[i + 1];
		}else if(k[i] == 1 && i == n - 1){
			t[i] = 1;
			f[i] = 0;
		}else if(k[i] == 0 && i == n - 1){
			f[i] = 1;
			t[i] = 0;
			
		}
	}
	for(int i = 0; i < n; i++){
		//cout << k [i] << " " << t[i] << " " << f[i] << endl;
		if(k[i] == 1){
			a+= t[i];
			if(f[i] % 2 == 0){
				a+= f[i] / 2;
			}
		}else{
			if(f[i] % 2 == 0){
				a+= f[i] / 2;
		}
	}
	cout << a << endl;
	return 0;
}
