#include <bits/stdc++.h>
using namespace std;
const int NMAX = 2e5;
int lsb(int x) { return x & (-x); }
int aib[NMAX + 2];
int query(int pos) {
  int r = 0;
  while (pos) {
    r += aib[pos];
    pos -= lsb(pos);
  }
  return r;
}
void update(int pos) {
  while (pos <= NMAX) {
    aib[pos]++;
    pos += lsb(pos);
  }
}
int v[NMAX + 2];
int main() {
  int N;
  cin >> N;
  int bad = 0;
  long long ans = 0;
  for (int i = 1; i <= N; ++i) {
    int nr;
    cin >> nr;
    ans += bad * (nr == 0);
    bad += nr;
  }
  cout << ans << '\n';
  return 0;
}
