#include<iostream>
#include<cmath>
#include<queue>
using namespace  std;
int main ()
{
    int n, sum=0, broqch=0, proizvedenie=0, br=0, neshto=0;
    cin>>n;
    int massiv [n];
    queue<int>q;
    queue<int>q2;
    q2.push (0);
    for (int i=0; i<n; i++)
    {
        cin>>massiv[i];
    }
    while (q2.front ()!=0){
        int i=0;
        i++;
        if (massiv[i]%2!=0){
            q2.push(1);
            q.push(i);
            q2.pop();
        }

    }
    for (int i=0; i<n; i++)
    {

        if (massiv[i]%2==0)
        {
            sum=sum+n+(n-i-1)*i;
            broqch++;
        }
        for (int q=i; q<n; q++){
            if (massiv[q]%2==0){
                br++;
            }
        }
        if (br>=2 or br==0){
            int z=i+1;
            while (massiv[z]%2!=0){
                neshto++;
                z++;
            }
            q.push(neshto);
            neshto=0;
        }
    }
    while (q.empty()!=1){
        if (q.front()!=0){
        proizvedenie=proizvedenie*q.front();
    }
    q.pop();
    }
    cout<<sum-proizvedenie;
    return 0;
}
