#include <bits/stdc++.h>
using namespace std;
int a[200000 + 5];
int a0[200000 + 5];
int a1[200000 + 5];
int main() {
  int i, j;
  int n;
  long long ret1, ret2;
  while (scanf("%d", &n) != EOF) {
    ret1 = ret2 = 0;
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    a[n] = -1;
    for (i = n - 1; i >= 0; i--) {
      if (a[i + 1] == 0)
        a1[i] = a1[i + 1] + 1;
      else
        a1[i] = a1[i + 1];
    }
    for (i = 1; i < n; i++) {
      if (a[i - 1] == 1) {
        a0[i] = a0[i - 1] + 1;
      } else
        a0[i] = a0[i - 1];
    }
    for (i = 0; i < n; i++) {
      if (a[i] == 0) ret1 += a0[i];
    }
    for (i = n - 1; i >= 0; i--)
      if (a[i] == 1) ret2 += a1[i];
    printf("%I64d\n", min(ret1, ret2));
  }
  return 0;
}
