#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

const ll Size=1e4+10;

void solve(){
    ll n,dist=0;
    cin>>n;
    ll ans=n*(n+1)/2;
    for(ll i=0,a;i<n;i++){
        cin>>a;
        if(a%2!=0){
            dist++;
        }else{
            ans-=dist*(dist+1)/2;
            dist=0;
        }
    }
    ans-=dist*(dist+1)/2;
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    while(t--){
        solve();
    }
    return 0;
}