#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
long long a[MAXN], dp[MAXN];
int main() {
  long long n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 2; i >= 0; i--) {
    dp[i] = dp[i + 1];
    if (a[i + 1] == 0) dp[i]++;
  }
  for (int i = 0; i < n; i++)
    if (a[i] == 1) ans += dp[i];
  cout << ans;
}
