#include <bits/stdc++.h>
using namespace std;
long long mod = 1;
int n, m;
int ar[200005];
long long res;
vector<int> v;
int main() {
  int i, j, t, tc = 1, a, b;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
  }
  res = 0;
  int cnt = 0;
  for (i = n - 1; i >= 0; i--) {
    if (ar[i] == 0)
      cnt++;
    else
      res += cnt;
  }
  cout << res << endl;
  return 0;
}
