#include <bits/stdc++.h>
using namespace std;
int n, a[211111];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long l = 0;
  long long r = 0;
  long long suml = 0;
  long long sumr = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      r++;
    }
    if (a[i] == 0) {
      suml += r;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      l++;
    }
    if (a[i] == 1) {
      sumr += l;
    }
  }
  cout << min(sumr, suml);
  return 0;
}
