#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long res = 0, counter = 0;
  for (int i = 0; i < n; i++) {
    int number;
    cin >> number;
    if (number == 1)
      counter++;
    else
      res += counter;
  }
  cout << res << endl;
}
