#include <bits/stdc++.h>
using namespace std;
long long dp[222222], d[211111], m;
int main() {
  cin >> m;
  dp[m + 1] = 0;
  for (int i = 1; i <= m; i++) {
    dp[i] = 0;
    cin >> d[i];
  }
  for (int i = m; i >= 1; i--) {
    if (d[i] == 0) {
      dp[i] = dp[i + 1] + 1;
    } else
      dp[i] = dp[i + 1];
  }
  long long ans = 0;
  for (int i = m; i >= 1; i--) {
    if (d[i] == 1) ans += dp[i];
  }
  cout << ans;
  return 0;
}
