#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  return is >> p.first >> p.second;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
  return os << p.first << " " << p.second;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int c = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x)
      c++;
    else
      ans += c;
  }
  cout << ans;
}
