#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    if (tmp == 0)
      ans += sum;
    else
      sum++;
  }
  cout << ans << endl;
}
