#include <bits/stdc++.h>
int a[200005];
int main(void) {
  int n, i, j, cnt;
  long long sum;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    for (i = 0, cnt = 0, sum = 0; i < n; i++) {
      if (a[i] == 1)
        cnt++;
      else
        sum += cnt;
    }
    printf("%I64d\n", sum);
  }
}
