#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];
  }
  long long int ans = 0, curr = 0;
  for (int i = n - 1; i >= 0; i--) {
    curr += (a[i] == 0);
    if (a[i] == 1) {
      ans += curr;
    }
  }
  cout << ans << endl;
  return 0;
}
