#include <bits/stdc++.h>
using namespace std;
const int maxn = 211111;
int h[maxn], zr[maxn], lo[maxn];
int main() {
  int n;
  scanf("%d", &n);
  if (n == 1) {
    scanf("%d", &n);
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", h + i);
    if (h[i] == 1)
      lo[i] = lo[i - 1] + 1;
    else
      lo[i] = lo[i - 1];
  }
  for (int i = n; i >= 1; i--) {
    if (h[i] == 0)
      zr[i] = zr[i + 1] + 1;
    else
      zr[i] = zr[i + 1];
  }
  long long ans1 = 0, ans2 = 0;
  for (int i = 1; i <= n; i++)
    if (h[i] == 1) ans1 += zr[i];
  for (int i = n; i >= 1; i--)
    if (h[i] == 0) ans2 += lo[i];
  cout << min(ans1, ans2) << endl;
}
