#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n, ans = 0, cnt = 0;
long long a[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) {
    cnt += (a[i] == 1);
    if (a[i] == 0) ans += cnt;
  }
  cout << ans;
  return 0;
}
