#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1000005;
const int oo = 1000000000;
const long long Base = 1000000007;
typedef int Tarr[MaxN];
Tarr a;
int n;
long long Res, tRes, d;
int main() {
  cin >> n;
  int x;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == 0)
      Res += d;
    else
      d++;
  }
  cout << Res;
  return 0;
}
