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