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