#include <bits/stdc++.h>
using namespace std;
int N, A[(200000)];
int lpsum[(200000)];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N;
  cin >> A[0];
  lpsum[0] = A[0] == 0 ? 1 : 0;
  for (int i = 1; i < N; i++) {
    cin >> A[i];
    lpsum[i] = lpsum[i - 1] + (A[i] == 0);
  }
  long long score = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == 1) {
      score += lpsum[N - 1] - lpsum[i];
    }
  }
  cout << score << endl;
  return 0;
}
