#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::deque;
using std::endl;
using std::map;
using std::max;
using std::min;
using std::multiset;
using std::pair;
using std::queue;
using std::set;
using std::sort;
using std::stack;
using std::string;
using std::vector;
int main() {
  int n;
  scanf("%d", &n);
  long long answer = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 0) {
      answer += cnt;
    } else {
      cnt++;
    }
  }
  cout << answer;
  return 0;
}
