#include <bits/stdc++.h>
using namespace std;
const int N = 200111;
int m[N], s[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> m[i];
  s[0] = m[0];
  for (int i = (1); i <= (n - 1); ++i) s[i] = m[i] + s[i - 1];
  long long ans = 0;
  for (int i = n - 1; i >= 0; --i)
    if (m[i] == 0) ans += s[i];
  cout << ans;
  return 0;
}
