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