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