#include <iostream>
using namespace std;
int sub(int n) {

    return (n * n + n) / 2;

}
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int ans = sub(n);
    bool counting = false;
    int bingo = 0;
    for (int i = 0; i < n; i++) {
        int curr;
        cin >> curr;
        if (curr % 2 == 1) {
            counting = true;
            bingo++;
        }
        if (counting && (i == n - 1 || curr % 2 == 0)) {
            counting = false;
            ans -= sub(bingo);
            bingo = 0;
        }
    }
    cout << ans;
    return 0;
}

