#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1.0);
const int maxn = 200009;
const int maxm = 1000009;
long long a[maxn], dp[maxn];
int main() {
  long long n;
  while (cin >> n) {
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
      dp[i] = dp[i - 1] + a[i];
    }
    for (int i = n; i >= 1; i--) {
      if (a[i] == 0) ans += dp[i];
    }
    cout << ans << endl;
  }
  return 0;
}
