#include <bits/stdc++.h>
using namespace std;
int n;
long long ans;
int a[200005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long cnt = 0LL;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0)
      cnt++;
    else
      ans += cnt;
  }
  cout << ans << endl;
  return 0;
}
