#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
int a[200010];
long long int sum[200010];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sum[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0)
      sum[i] = sum[i + 1] + 1;
    else
      sum[i] = sum[i + 1];
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      ans = ans + sum[i];
    }
  }
  cout << ans << endl;
}
