#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using dl = double;
using ld = long double;
using ull = unsigned long long;
const long N = 3e5 + 10;
const long maxn = 5e5 + 10;
ll aarray[N];
ll magic[510][510];
vector<ll> primes;
bool check[1000001];
ll large[10000005];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
ll vis[N];
map<ll, ll> mp;
ll psum[N];
void solve() {
  ll i, j, k, m, n, l, r, q, p, ans, sum = 0;
  string str;
  bool yes = true;
  vector<ll> v;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> aarray[i];
  }
  for (i = n; i >= 1; i--) {
    if (aarray[i] == 0) {
      psum[i] = psum[i + 1] + 1;
    } else {
      psum[i] = psum[i + 1];
    }
  }
  ans = 0;
  for (i = 1; i < n; i++) {
    if (aarray[i]) {
      ans += psum[i + 1];
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string str;
  ll i, j, n, m, k, t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
