#include <bits/stdc++.h>
using namespace std;
int modulo(int a, int b, int c) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % c;
    }
    y = (y * y) % c;
    b /= 2;
  }
  return x % c;
}
long long modulo(long long a, long long b, long long c) {
  long long x = 0, y = a % c;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x + y) % c;
    }
    y = (y * 2) % c;
    b /= 2;
  }
  return x % c;
}
int a[200000];
int one[200000];
int zero[200000];
int main() {
  int i, j, n, c = 0;
  n = 200000;
  long long val = 0, val2 = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) val += c;
    if (a[i] == 1) c++;
  }
  c = 0;
  for (i = n - 1; i >= 0; i--) {
    if (a[i] == 1) val2 += c;
    if (a[i] == 0) c++;
  }
  cout << min(val, val2) << endl;
  return 0;
}
