#include <bits/stdc++.h>
int N, A[200005], C[200005][2], T[2];
int main(void) {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    for (int j = 0; j < 2; j++) C[i][j] = C[i - 1][j];
    C[i][A[i]]++;
    T[A[i]]++;
  }
  long long P = 0;
  for (int i = 1; i <= N; i++) {
    if (A[i] == 0) {
      P += (long long)(C[i - 1][1]);
    }
  }
  printf("%I64d\n", P);
  return 0;
}
