func_code_string: #include <bits/stdc++.h>   using namespace std;   inline void readi(int &x);   const int maxn = 300005;   int n, b[maxn], id[maxn], rk[maxn];   double fl[maxn], fr[maxn];   bool cmpb(const int &i, const int &j) { return b[i] < b[j]; }   struct node {     double div, dta;     node *lc, *rc;     inline void downdate() {       if (div != 1)         lc->div *= div, lc->dta *= div, rc->div *= div, rc->dta *= div, div = 1;       if (dta != 0) lc->dta += dta, rc->dta += dta, dta = 0;     }     inline void modify(int l, int r, const int &a, const int &b, const double &c,                        const double &d) {       if (l >= a && r <= b)         div *= c, dta *= c, dta += d;       else {         int mid = l + r >> 1;         downdate();         if (a <= mid) lc->modify(l, mid, a, b, c, d);         if (b > mid) rc->modify(mid + 1, r, a, b, c, d);       }     }     inline double get(int l, int r, const int &p) {       if (l == r) return dta;       int mid = l + r >> 1;       downdate();       if (p <= mid)         return lc->get(l, mid, p);       else         return rc->get(mid + 1, r, p);     }   } ndl[maxn * 3], *root;   int ns;   node *build(int l, int r) {     node *c = ndl + ns++;     c->dta = 0;     c->div = 1;     if (l == r)       c->lc = c->rc = NULL;     else {       int mid = l + r >> 1;       c->lc = build(l, mid);       c->rc = build(mid + 1, r);     }     return c;   }   void build() { ns = 1, root = build(1, n); }   void init() {     readi(n);     for (int i = 1; i <= n; i++) readi(b[i]), id[i] = i;     sort(id + 1, id + n + 1, cmpb);     for (int i = 1; i <= n; i++) rk[id[i]] = i;   }   void work() {     build();     for (int i = 1; i <= n; i++) {       root->modify(1, n, 1, n, 1, 1);       if (rk[i] > 1) root->modify(1, n, 1, rk[i] - 1, .5, 0);       fl[i] = root->get(1, n, rk[i]) / 2;     }     build();     for (int i = n; i >= 1; i--) {       root->modify(1, n, 1, n, 1, 1);       if (rk[i] > 1) root->modify(1, n, 1, rk[i] - 1, .5, 0);       fr[i] = root->get(1, n, rk[i]) / 2;     }     double ans = 0;     for (int i = 1; i <= n; i++) ans += fl[i] * fr[i] * b[i];     ans /= (double)n * n;     printf( %lf , (double)ans * 2);   }   int main() {     init();     work();     return 0;   }   inline void readi(int &x) {     char c;     for (c = getchar(); c >  9  || c <  0 ; c = getchar())       ;     x = c ^  0 ;     for (c = getchar(); c >=  0  && c <=  9 ; c = getchar())       x = x * 10 + (c ^  0 );   }   