#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000000;
int n;
vector<int> num, sum;
int main() {
  cin >> n;
  num.resize(n);
  sum.resize(n + 1);
  for (int i = 0; i < n; ++i) cin >> num[i];
  long long res = 0;
  sum[0] = 0;
  for (int i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1] + num[i - 1];
  }
  for (int i = 1; i < n; ++i) {
    if (!num[i]) res += sum[i + 1] - sum[0];
  }
  cout << res << endl;
  return 0;
}
