#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
long long one[MAXN], zero[MAXN], ans1, ans2, a[MAXN], n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    one[i] = one[i - 1];
    if (a[i] == 1) one[i]++;
  }
  for (int i = n; i >= 1; i--) {
    zero[i] = zero[i + 1];
    if (a[i] == 0) zero[i]++;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) ans1 += one[i];
    if (a[i] == 1) ans2 += zero[i];
  }
  cout << min(ans1, ans2);
}
