#include<bits/stdc++.h>
using namespace std;
int a[10001];
vector<int> v;
int main(){
    int n;
    cin>>n;
    int br=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==1){
            br++;
            if(i==n-1){
                v.push_back(br);
            }
        }else{
            if(br!=0){
                v.push_back(br);
            }
            br=0;
        }
    }
    /*for(int i=0;i<v.size();i++){
        cout<<v[i]<<" ";
    }
    cout<<endl;
    */
    long long s1=0;
    for(int i=0;i<v.size();i++){
        s1=s1+v[i]*(v[i]-1)/2+v[i];
    }
    //cout<<s1<<endl;
    //cout<<n*(n-1)/2+n<<endl;
    long long ans=n*(n-1)/2+n-s1;
    cout<<ans;
return 0;
}
