#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f, N = 2e5 + 5, mod = 1e9 + 7;
int n, arr[N], o, z;
long long ans1, ans2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", arr + i);
  for (int i = n; i >= 1; --i) {
    if (arr[i]) ans1 += z;
    z += !arr[i];
  }
  for (int i = 1; i <= n; ++i) {
    if (!arr[i]) ans2 += o;
    o += arr[i];
  }
  cout << min(ans1, ans2);
  return 0;
}
