#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 2;
using namespace std;
void solve();
void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fastIO();
  solve();
}
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int cnt[n];
  cnt[n - 1] = 0;
  if (a[n - 1] == 0) cnt[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] == 0)
      cnt[i] = cnt[i + 1] + 1;
    else
      cnt[i] = cnt[i + 1];
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) ans += cnt[i];
  }
  cout << ans << "\n";
}
