#include<bits/stdc++.h>
using namespace std;
int arr[100000];
int ch[1000000];
int n;
int main () {
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> ch[i];
        ch[i] = ch[i] % 2;
        if(ch[i] == 0){
            if(i == 0){
                arr[i] = 1;
            }else{
                arr[i] = arr[i - 1] + 1;
            }
        }else {
            if(i != 0){
                arr[i] = arr[i - 1];
            }
        }
    }
    unsigned long long answer = 0;
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            if(ch[j] == 0 || ch[i] == 0 ){
                answer++;
            }else{
                if(arr[j] - arr[i] >= 1){
                    answer++;
                }
            }
        }
    }
    cout << answer << "\n";


    return 0;
}