#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
int main() {
  long long cnt = 0;
  int n;
  cin >> n;
  int x;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 1) cnt++;
    if (x == 0) ans += cnt;
  }
  cout << ans << endl;
  return 0;
}
