#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int Minf = 0x7f7f7f7f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const long long MINF = 0x7f7f7f7f7f7f7f7fll;
const int N = 2e5 + 50;
int a[N], t[N], s[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i)
    scanf("%d", &a[i]), s[i] = s[i - 1] + (a[i] == 1);
  for (int i = (n); i >= (1); --i) t[i] = t[i + 1] + (a[i] == 0);
  long long fans = 0, ans = 0;
  for (int i = (1); i <= (n); ++i)
    if (a[i] == 1) ans += t[i + 1];
  for (int i = (1); i <= (n); ++i)
    if (a[i] == 0) fans += s[i - 1];
  cout << min(fans, ans) << endl;
}
