func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n;   long long N[100006];   long long sum[1000006], S[1000006];   long long t[1000006];   long long t1[1000006];   long long lowbit(long long u) { return u & (-u); }   void add(long long u, long long w) {     while (u <= n) {       t[u] += w;       u += lowbit(u);     }   }   long long Find(long long u) {     long long ans = 0;     while (u) {       ans += t[u];       u -= lowbit(u);     }     return ans;   }   void add1(long long u, long long w) {     while (u <= n) {       t1[u] += w;       u += lowbit(u);     }   }   long long Find1(long long u) {     long long ans = 0;     while (u) {       ans += t1[u];       u -= lowbit(u);     }     return ans;   }   double ans;   signed main() {     scanf( %lld , &n);     for (long long i = 1; i <= n; i++) scanf( %lld , &N[i]);     for (long long i = 1; i <= n; i++) {       sum[i] += Find(n) - Find(N[i]);       S[i] += Find1(n) - Find1(N[i]);       if (sum[i] != 0)         ans += ((double)(n * (n + 1ll) / 2ll) * sum[i] -                 (double)(n - i + 1ll) * S[i]) /                (double)(n * (n + 1ll) / 2ll);       add(N[i], 1);       add1(N[i], i);     }     for (long long i = 2; i <= n; i++)       ans += (double)((i - 1) * i) / 2.00 / 2.00 * (double)(n - i + 1) /              (double)(n * (n + 1ll) / 2ll);     printf( %.12lf n , ans);     return 0;   }   