#include <bits/stdc++.h>
const int N = 2e5 + 5;
bool v[N];
int main() {
  int n;
  long long ans = 0, nr0 = 0;
  std::cin >> n;
  for (int i = 1; i <= n; i++) std::cin >> v[i], nr0 += (v[i] == 0);
  for (int i = 1; i <= n; i++)
    if (v[i])
      ans += nr0;
    else
      nr0--;
  std::cout << ans;
}
