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