#include<iostream>
#include<vector>
using namespace std;
int main(){
    long long N,sum=0,a[10000],s=0,k=0;
    bool sreshtnato=false;
    cin>>N;
    for(long long i=0;i<N;i++){
        cin>>a[i];
    }
    for(long long i=0;i<N;i++){
        if(sreshtnato==true && a[i]%2!=0){
            s++;
        }
        if(sreshtnato==false && a[i]%2==0){
            sreshtnato=true;
        }
        if(sreshtnato==true && a[i]%2==0){
            if(k==0){
                s=i;
            }
            sum+=s+N-i+s*(N-i-1);
            s=0;
            k++;
        }
    }
    cout<<sum;
return 0;
}
