#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, soma = 0, minimo = 0;
  int a[250000];
  cin >> n;
  for (long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i])
      soma++;
    else
      minimo += soma;
  }
  cout << minimo;
  return 0;
}
