#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1, c = 0; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    if (!x)
      ans += c;
    else
      ++c;
  }
  printf("%I64d\n", ans);
  return 0;
}
