#include <bits/stdc++.h>
using namespace std;
const int MAX = 1 << 18;
int main() {
  int n, one = 0;
  cin >> n;
  long long count = 0;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    if (num == 1)
      one++;
    else
      count += one;
  }
  cout << count;
  return 0;
}
