#include <bits/stdc++.h>
using namespace std;
long long x, Now, Res, n;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == 1)
      Now++;
    else
      Res += Now;
  }
  cout << Res << endl;
}
