#include <bits/stdc++.h>
using namespace std;
int a[2000005], c0[2000005], c1[2000005];
int main() {
  int n;
  long long ans = 0ll;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    c1[i] = c1[i - 1] + a[i];
  }
  for (int i = n; i > 0; i--) {
    c0[i] = c0[i + 1] + (a[i] + 1) % 2;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1)
      ans += c0[i + 1];
    else
      ans += c1[i - 1];
  }
  printf("%I64d\n", ans / 2);
  return 0;
}
