#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long int sol = 0;
  int num1 = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x == 0)
      sol += num1;
    else
      num1++;
  }
  cout << sol << endl;
}
