#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 10;
int a[MAXN], sum[MAXN];
int main() {
  memset(sum, 0, sizeof(sum));
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long s = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0)
      sum[i - 1] = sum[i] + 1;
    else
      sum[i - 1] = sum[i];
  }
  for (int i = 0; i < n; i++)
    if (a[i]) s += sum[i];
  printf("%I64d", s);
  return 0;
}
