#include <bits/stdc++.h>
using namespace std;
__attribute__((constructor)) void Init() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
}
int main() {
  int n, m = 0;
  cin >> n;
  int64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a == 0)
      ans += m;
    else
      ++m;
  }
  cout << ans << endl;
  return 0;
}
