#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    int i;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    int pref=0;
    int brparnih=1,brneparnih=0;
    for(i=1;i<=n;i++){
        pref+=a[i-1];
        if(pref%2==0){
            brparnih++;
        }
        else{
            brneparnih++;
        }
    }
    long long res=(1ll*brparnih*(brparnih-1))/2+(1ll*brneparnih*(brneparnih-1))/2;
    cout<<res<<endl;
    return 0;
}
