#include <bits/stdc++.h>
using namespace std;
long long int ans, cow[200005], lose[200005];
int main(int argc, char const *argv[]) {
  int n;
  while (cin >> n) {
    ans = 0;
    memset(lose, 0, sizeof(lose));
    for (int i = 1; i <= n; i++) {
      cin >> cow[i];
      lose[i] = lose[i - 1] + cow[i];
      if (cow[i] == 0) ans += lose[i];
    }
    cout << ans << endl;
  }
  return 0;
}
