#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, rht = 0;
  long long ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    if (t == 0)
      ans += rht;
    else
      rht++;
  }
  printf("%lld", ans);
  return 0;
}
