#include <bits/stdc++.h>
using namespace std;
long long int n, a[200010], c, an1, an2, n1, n0;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1)
      n1++;
    else
      n0++;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      c++;
    } else
      an1 += (n0 - c);
  }
  c = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 1) {
      c++;
    } else
      an2 += (n1 - c);
  }
  cout << min(an1, an2) << endl;
}
