#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long scare = 0;
  long long lose = 0;
  for (int i = 0; i < N; i++) {
    int facing;
    cin >> facing;
    if (facing == 1)
      scare++;
    else
      lose += scare;
  }
  cout << lose;
  return 0;
}
