#include <bits/stdc++.h>   using namespace std;   long long cnt[5], ans1, ans2;   int main() {     int n, a[200010];     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] == 1)         cnt[1]++;       else         cnt[0]++;     }     for (int i = 0; i < n; i++) {       if (a[i] == 0)         cnt[0]--;       else {         ans1 += cnt[0];       }     }     cout << ans1;     return 0;   }   