#include <bits/stdc++.h>
using namespace std;
int a[200020];
int cnt[200020];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    cnt[0] = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%d", a + i);
      cnt[i] = cnt[i - 1] + a[i];
    }
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (a[i]) ans += n - i - (cnt[n] - cnt[i]);
    }
    cout << ans << endl;
  }
  return 0;
}
