#include <bits/stdc++.h>
using namespace std;
long long x, y, xx, j, yy, n, m, t, k, l, ans, ans1, o, i;
struct my {
  int x;
  int l;
  int r;
};
my a[200000 + 10];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i].x;
  for (i = 1; i <= n; i++) {
    a[i].r = o;
    if (a[i].x == 1) o++;
  }
  o = 0;
  for (i = n; i >= 1; i--) {
    a[i].l = o;
    if (a[i].x == 0) o++;
  }
  o = 0;
  for (i = n; i >= 1; i--) {
    if (a[i].x == 1) ans += a[i].l;
  }
  for (i = 1; i <= n; i++) {
    if (a[i].x == 0) ans1 += a[i].r;
  }
  cout << min(ans1, ans);
}
