#include <bits/stdc++.h>
using namespace std;
long long n, m, k, l, r, ans, c, a, b, A[201000], B[201000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) cin >> A[i];
  for (int i = (int)(n)-1; i >= 0; --i) B[i] = B[i + 1] + 1 - A[i];
  for (int i = 0; i < (int)(n); ++i) {
    if (A[i] == 1) ans += B[i];
  }
  cout << ans << endl;
  return 0;
}
