#include <bits/stdc++.h>
using namespace std;
long long n, cnt = 0, ans = 0;
int main() {
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      ans += cnt;
    } else {
      cnt++;
    }
  }
  cout << ans;
}
