#include <bits/stdc++.h>
using namespace std;
int ar[200001], r[200001];
int main() {
  int n, i;
  cin >> n;
  long long ans = 0;
  for (i = (1); i <= (n); ++i) {
    scanf("%d", &ar[i]);
    r[i] = r[i - 1] + ar[i];
    if (!ar[i]) ans += r[i];
  }
  cout << ans << endl;
}
