#include <bits/stdc++.h>
using namespace std;
int n, dir[200005];
long long cnt, le;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &dir[i]);
    if (dir[i] == 0) le++;
  }
  for (int i = 0; i < n; i++) {
    if (dir[i] == 1)
      cnt += le;
    else
      le--;
  }
  printf("%I64d", cnt);
  return 0;
}
