#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int a[maxn], b[maxn][2];
int main() {
  int n, x, y;
  while (scanf("%d", &n) != EOF) {
    int i;
    memset(b, 0, sizeof(b));
    x = 0;
    y = 0;
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == 0) {
        x++;
        b[i][0] = b[i - 1][0] + 1;
        b[i][1] = b[i - 1][1];
      }
      if (a[i] == 1) {
        y++;
        b[i][1] = b[i - 1][1] + 1;
        b[i][0] = b[i - 1][0];
      }
    }
    long long int ans1 = 0, ans2;
    for (i = 1; i <= n; i++) {
      if (a[i] == 0) ans1 += b[i - 1][1];
      if (a[i] == 1) ans2 += (x - b[i][0]);
    }
    long long int ans = min(ans1, ans2);
    printf("%I64d\n", ans);
  }
}
