#include<bits/stdc++.h>
using namespace std;
int n;
int arr[10007];
int main()
{
    cin>>n;
    for (int q=0;q<n;q++) cin>>arr[q];
    long long ans=n*(n+1);ans/=2;
    long long br=0;
    for (int q=0;q<n;q++)
    {
        if (arr[q]%2==1) br++;
        else
        {
            long long cur=br*(br+1)/2;
            ans-=cur;
            br=0;
        }
    }
    long long cur=br*(br+1)/2;
    ans-=cur;
    cout<<ans<<"\n";
}
