#include <bits/stdc++.h>
using namespace std;
long long a[200005], sum[200005];
int main() {
  long long n, s = 0, i;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = n; i >= 1; i--) {
    sum[i - 1] = sum[i];
    if (a[i] == 0) sum[i - 1]++;
  }
  for (i = 1; i < n; i++) {
    if (a[i] == 1) {
      s = sum[i] + s;
    }
  }
  printf("%lld", s);
}
