#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int c[n], b[n];
  memset(c, 0, sizeof(c));
  memset(b, 0, sizeof(b));
  if (a[n - 1] == 0) c[n - 1] = 1;
  if (a[0] == 1) b[0] = 1;
  for (int i = 1; i < n; i++) b[i] = b[i - 1] + (a[i] == 1);
  for (int i = n - 2; i >= 0; i--) c[i] = c[i + 1] + (a[i] == 0);
  long long res1 = 0, res2 = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) res1 += c[i];
    if (a[i] == 0) res2 += b[i];
  }
  cout << min(res1, res2) << endl;
  return 0;
}
