func_code_string: #include <bits/stdc++.h>   const long long md = 1e9 + 7;   const int Inf = 1e9;   const long long Inf64 = 1e18;   const long long MaxN = 1e6 + 100;   const long double eps = 1e-15;   using namespace std;   long long Tree[4 * MaxN];   long long getSum(long long l, long long r, long long x, long long y,                    long long id) {     if (l == x && r == y) {       return Tree[id];     } else {       long long mid = (l + r) / 2;       if (mid >= y) {         return getSum(l, mid, x, y, 2 * id + 1);       } else if (mid + 1 <= x) {         return getSum(mid + 1, r, x, y, 2 * id + 2);       } else {         return getSum(l, mid, x, mid, 2 * id + 1) +                getSum(mid + 1, r, mid + 1, y, 2 * id + 2);       }     }   }   void edit(long long l, long long r, long long x, long long id) {     if (l == r) {       Tree[id]++;     } else {       long long mid = (l + r) / 2;       if (mid >= x) {         edit(l, mid, x, 2 * id + 1);         Tree[id] = Tree[2 * id + 1] + Tree[2 * id + 2];       } else {         edit(mid + 1, r, x, 2 * id + 2);         Tree[id] = Tree[2 * id + 1] + Tree[2 * id + 2];       }     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long N;     cin >> N;     vector<pair<long long, long long> > Zip(N);     for (int i = 0; i < N; i++) {       long long a;       cin >> a;       Zip[i] = {a, i};     }     sort(Zip.begin(), Zip.end());     vector<long long> Ans(N);     for (int i = 0; i < N; i++) {       long long t = getSum(0, N - 1, Zip[i].second, N - 1, 0);       Ans[Zip[i].second] = t;       edit(0, N - 1, Zip[i].second, 0);     }     fill(Tree, Tree + 4 * MaxN, 0);     reverse(Zip.begin(), Zip.end());     long long Res = 0;     for (int i = 0; i < N; i++) {       long long t = getSum(0, N - 1, 0, Zip[i].second, 0);       Res += Ans[Zip[i].second] * t;       edit(0, N - 1, Zip[i].second, 0);     }     cout << Res;     cerr <<   n           <<  Time execute:   << clock() / (double)CLOCKS_PER_SEC <<   sec           <<   n ;     return 0;   }   