func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1000010;   long long a[maxn], s1, s2;   double ans[maxn];   int l[maxn], r[maxn];   vector<int> gao[6][maxn];   int n, m, pos;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     l[1] = 1;     for (int i = 2; i <= n; i++) {       l[i] = i;       while (l[i] != 1 && a[l[i] - 1] > a[i]) l[i] = l[l[i] - 1];     }     r[n] = n;     for (int i = n - 1; i >= 1; i--) {       r[i] = i;       while (r[i] != n && a[r[i] + 1] >= a[i]) r[i] = r[r[i] + 1];     }     for (int i = 1; i <= n; i++) {       int a1 = r[i] + 1 - i;       int a2 = i + 1 - l[i];       if (a1 <= a2) {         gao[0][a1].push_back(i);         gao[1][a2 + 1].push_back(i);         gao[2][r[i] - l[i] + 3].push_back(i);       } else {         gao[3][a2].push_back(i);         gao[4][a1 + 1].push_back(i);         gao[5][r[i] - l[i] + 3].push_back(i);       }     }     for (int i = 1; i <= n; i++) s1 += a[i];     for (int L = 1; L <= n; L++) {       for (int i = 0, sz = gao[0][L].size(); i < sz; i++) {         pos = gao[0][L][i];         s1 -= a[pos];         s2 += (r[pos] - pos + 1LL) * a[pos];       }       for (int i = 0, sz = gao[1][L].size(); i < sz; i++) {         pos = gao[1][L][i];         s2 += (pos - l[pos] + 1LL) * a[pos];         s1 -= a[pos];       }       for (int i = 0, sz = gao[2][L].size(); i < sz; i++) {         pos = gao[2][L][i];         s2 -= (r[pos] - l[pos] + 2LL) * a[pos];         s1 += a[pos];       }       for (int i = 0, sz = gao[3][L].size(); i < sz; i++) {         pos = gao[3][L][i];         s1 -= a[pos];         s2 += (pos - l[pos] + 1LL) * a[pos];       }       for (int i = 0, sz = gao[4][L].size(); i < sz; i++) {         pos = gao[4][L][i];         s2 += (r[pos] - pos + 1LL) * a[pos];         s1 -= a[pos];       }       for (int i = 0, sz = gao[5][L].size(); i < sz; i++) {         pos = gao[5][L][i];         s2 -= (r[pos] - l[pos] + 2LL) * a[pos];         s1 += a[pos];       }       long long temp = s1 * L + s2;       ans[L] = 1.0 * temp / (n - L + 1);     }     scanf( %d , &m);     while (m--) {       int k;       scanf( %d , &k);       printf( %.10f n , ans[k]);     }   }   