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