#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n;
long long sum, ans;
int main() {
  n = read();
  static int x;
  for (int i = 1; i <= n; i++) {
    x = read();
    if (x)
      sum++;
    else
      ans += sum;
  }
  printf("%I64d\n", ans);
  return 0;
}
