#include <bits/stdc++.h>
using namespace std;
int x[200200], zero[200200];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> x[i];
  for (int i = n; i >= 1; --i) zero[i] = zero[i + 1] + 1 - x[i];
  long long res = 0;
  for (int i = 1; i <= n; ++i)
    if (x[i] == 1) res += zero[i];
  cout << res;
  return 0;
}
