#include <bits/stdc++.h>
const int N = 200010;
using namespace std;
long long n, a[N], sum, cnt;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i]) {
      cnt++;
    } else {
      sum += cnt;
    }
  }
  cout << sum << endl;
  return 0;
}
