#include <bits/stdc++.h>
using namespace std;
long long sum, ans, n, x;
int main() {
  cin >> n;
  while (n--) {
    cin >> x;
    if (x != 0)
      sum++;
    else
      ans += sum;
  }
  cout << ans << endl;
  return 0;
}
