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