#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int br=0;
int ans=0;
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a%2==1){
        br++;
    }
    if(a%2==0 or i==n-1){
        ans+=br+br*(br-1)/2;
        br=0;
        //cout<<i<<" ";
    }
}
cout<<n+n*(n-1)/2-ans;
return 0;
}
