#include <bits/stdc++.h>
using namespace std;
int N;
int seq[200200];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", seq + i);
  }
  long long result = 0;
  long long current = 0;
  for (int i = 0; i < N; ++i) {
    if (seq[i] == 1)
      ++current;
    else
      result += current;
  }
  printf("%I64d\n", result);
}
