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