#include <bits/stdc++.h>
using namespace std;
long double pi = 3.14159265358979323846;
int main() {
  long long n;
  cin >> n;
  int* arr = new int[n];
  long long c0 = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    c0 += arr[i] == 0;
  }
  long long cs = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0)
      cs++;
    else
      sum += c0 - cs;
  }
  cout << sum;
  return 0;
}
