#include <bits/stdc++.h>
using namespace std;
inline int ___INT() {
  int ret;
  scanf("%d", &ret);
  return ret;
}
int main() {
  int n = ___INT();
  int cntRight = 0;
  long long ans = 0;
  for (int i = 0; i < (n); ++i) {
    int x = ___INT();
    if (x == 1)
      ++cntRight;
    else
      ans += cntRight;
  }
  cout << ans << endl;
  return 0;
}
