#include <stdio.h>
int main(void){
  long long int n, ans, i. tmp = 0, tmp2 = 0, ii, iii;
  int t[200005] ={}, s[200005] = {};
  for (i = 0; i < n; i++)
  {
      scanf("%d", t + i);
        if (t[i] = 1)
            tmp++;
  }
    ans = ((tmp + 1) / 2)  ((tmp + 1) / 2) + (tmp / 2) * ((tmp  + 1) % 2);
    for (i = 0; i < tmp; i++)
        s[i] = 1;
    for (i = 1; i <= n; i++)
    {
        if (t[n - i] == 0)
        {
            t[n - i] == 1;
            for (iii = tmp + 1; iii < tmp + 1 - i; iii--)
            {
                s[iii] = s[iii - 1];
            }
            s[tmp - i + 1] = 0;
            tmp++;
            for (ii = 0; ii < tmp; ii++)
            {
                if (ii % 2 == 1 && s[i] == 1)
                    ans++;
            }
        }
    }
    printf("%lld", ans);
    
    
   return (0);
}
