#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 100500;
long long n, res, a[N], t[N];
void update(int x, int val) {
  for (int i = x; i <= n; i = (i | (i + 1))) t[i] += val;
}
long long sum(int k) {
  long long res = 0;
  for (int j = k; j >= 1; j = (j & (j + 1)) - 1) res += t[j];
  return res;
}
long long get(int l, int r) { return (sum(r) - sum(l - 1)); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (!a[i]) update(i, 1);
  }
  for (int i = 1; i <= n; i++)
    if (a[i]) res += get(i, n);
  cout << res;
  return 0;
}
