#include <bits/stdc++.h>
using namespace std;
inline void R(int &x) {
  char ch = getchar();
  x = 0;
  for (; ch < '0'; ch = getchar())
    ;
  for (; ch >= '0'; ch = getchar()) x = x * 10 + ch - '0';
}
const int N = 200005;
int n, a[N];
long long ans = 0;
int main() {
  R(n);
  for (int i = 1; i <= n; ++i) R(a[i]);
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i] == 1)
      ++cnt;
    else
      ans += cnt;
  }
  printf("%I64d\n", ans);
  return 0;
}
