#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, a[200005];
long long sum[200005];
int main() {
  long long ans;
  while (scanf("%d", &n) != EOF) {
    ans = 0;
    memset(a, 0, sizeof(a));
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == 1)
        sum[i] = sum[i - 1] + 1;
      else
        sum[i] = sum[i - 1];
    }
    for (int i = n; i >= 1; i--) {
      if (a[i] == 0) ans += sum[i];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
