#include <bits/stdc++.h>
using namespace std;
int arr[200000 + 10];
int arr2[200000 + 10];
int main() {
  int n, num1 = 0, num2 = 0, tem1, l1 = 0, l2 = 0, num = 0;
  long long ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tem1;
    if (tem1 == 0) {
      ans += num;
    } else
      num++;
  }
  cout << ans;
  return 0;
}
