#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000 + 10;
int a[MAX_N];
int b[MAX_N];
int c[MAX_N];
int main() {
  int n;
  cin >> n;
  int C, B;
  B = 0;
  C = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      C++;
    } else {
      B++;
    }
  }
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] == 1) {
      b[i] = b[i - 1] + 1;
      c[i] = c[i - 1];
    } else {
      b[i] = b[i - 1];
      c[i] = c[i - 1] + 1;
    }
  }
  long long ans1, ans2;
  ans1 = ans2 = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1) {
      ans1 += C - c[i];
    }
  }
  for (int i = n; i >= 1; i--) {
    if (a[i] == 0) {
      ans2 += b[i];
    }
  }
  cout << min(ans1, ans2) << endl;
}
