func_code_string: #include <bits/stdc++.h>   using namespace std;   map<long long, long long> C;   long long B[1100000], pre[1100000], suf[1100000], A[1100000], tot, i, n,       c[1100000], ans;   void add(long long x) {     for (; x <= n; x += (x & (-x))) c[x]++;   }   long long getsum(long long x) {     long long sum = 0;     for (; x >= 1; x -= (x & (-x))) sum += c[x];     return sum;   }   int main() {     scanf( %I64d , &n);     for (i = 1; i <= n; i++) cin >> A[i];     for (i = 1; i <= n; i++) C[A[i]]++, pre[i] = C[A[i]];     C.clear();     for (i = n; i >= 1; i--) C[A[i]]++, suf[i] = C[A[i]];     for (i = n; i >= 1; i--) {       ans += getsum(pre[i] - 1);       add(suf[i]);     }     printf( %I64d n , ans);   }   