#include <bits/stdc++.h>
using namespace std;
int num[200010];
char str[200010];
int n, k, m, c;
int main() {
  while (cin >> n) {
    int count = 0, cnt = 0;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &num[i]);
      if (num[i] == 0) count++;
    }
    for (int i = 0; i < n; i++) {
      if (num[i] == 1) {
        ans += count - cnt;
      } else
        cnt++;
    }
    cout << ans << endl;
  }
  return 0;
}
