#include <bits/stdc++.h>
using namespace std;
const int inf = 200005;
int a[inf], dp[inf];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      dp[i] = dp[i - 1] + a[i];
    }
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 0) sum += dp[i];
    }
    cout << sum << endl;
  }
  return 0;
}
