#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000009, pp = (1 << 17) - 1;
int n, a[maxn], d[maxn], c[pp + 8], d1[maxn];
int l[maxn], r[maxn];
long long s0[maxn], s1[maxn], s[maxn];
struct Tprogram {
  void open() {
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
  }
  void close() {}
  void tong_pai() {
    for (int i = 1; i <= n; i++) c[a[i] & pp]++;
    for (int i = 1; i <= pp; i++) c[i] += c[i - 1];
    for (int i = n; i >= 1; i--) d[c[a[i] & pp]--] = i;
    memset(c, 0, sizeof(c));
    for (int i = 1; i <= n; i++) c[a[d[i]] >> 16]++;
    for (int i = 1; i <= pp; i++) c[i] += c[i - 1];
    for (int i = n; i >= 1; i--) d1[c[a[d[i]] >> 16]--] = d[i];
    for (int i = 1; i <= n; i++) d[i] = d1[i];
  }
  void init() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    tong_pai();
  }
  void work() {
    for (int i = 1; i <= n; i++) l[i] = i - 1, r[i] = i + 1;
    for (int i = n; i >= 1; i--) {
      int j = d[i];
      int L = l[j] + 1, R = r[j] - 1;
      L = j - L, R = R - j;
      if (L > R) swap(L, R);
      s1[L + 2] += (L + 1) * (long long)a[j];
      s0[1] += a[j];
      s0[L + 2] -= a[j];
      s1[L + 2] -= (L + 1) * (long long)a[j];
      s0[R + 2] -= a[j];
      s0[R + L + 2] += a[j];
      s1[R + L + 2] -= a[j];
      r[l[j]] = r[j];
      l[r[j]] = l[j];
    }
    for (int i = 1; i <= n; i++) {
      s0[i] += s0[i - 1];
      s1[i] += s0[i] + s1[i - 1];
    }
    int q, k;
    scanf("%d", &q);
    for (int i = 1; i <= q; i++) {
      scanf("%d", &k);
      printf("%.9lf\n", (double)s1[k] / (n - k + 1));
    }
  }
} Program;
int main() {
  Program.init();
  Program.work();
  return 0;
}
