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

int n;
int a[10002];
vector <long long> v;
long long ans, br;

int main () {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

cin >> n;

for (int i=0; i < n; i++) {
    cin >> a[i];
    if (a[i]%2 == 1) {
        br++;
    }
    if (a[i] % 2 == 0 or i == n-1) {
        v.push_back(br);
        br=0;
    }

}

ans = n*(n+1)/2;

for (int i=0; i < v.size(); i++) {
    //cout << v[i] << " ";
    ans -= v[i]*(v[i]+1)/2;
}
//cout << endl;
cout << ans << endl;

return 0;
}
