#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
int a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0)
      ans += cnt;
    else
      cnt++;
  }
  printf("%I64d\n", ans);
  return 0;
}
