#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio();
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  int cnt[n];
  cnt[0] = (a[0] == 0);
  for (int i = 1; i < n; ++i) cnt[i] = cnt[i - 1] + (a[i] == 0);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 0) continue;
    ans += (cnt[n - 1] - cnt[i]);
  }
  cout << ans << endl;
  return 0;
}
