#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int MOD = 1000000007;
int n, a[N];
int r[N];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i > 0; i--) {
    r[i] = r[i + 1] + (a[i] == 0);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++)
    if (a[i] == 1) ans += r[i + 1];
  cout << ans << endl;
  return 0;
}
