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