#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];
struct edge {
  int e, nx;
} e[3 * maxn];
int head[maxn][6], cnt;
inline void add(int i, int j, int to) {
  cnt++;
  e[cnt].e = to;
  e[cnt].nx = head[i][j];
  head[i][j] = cnt;
}
int n, m, k, 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) {
      add(a1, 0, i);
      add(a2 + 1, 1, i);
      add(r[i] - l[i] + 3, 2, i);
    } else {
      add(a2, 3, i);
      add(a1 + 1, 4, i);
      add(r[i] - l[i] + 3, 5, i);
    }
  }
  for (int i = 1; i <= n; i++) s1 += a[i];
  for (int L = 1; L <= n; L++) {
    for (int i = head[L][0]; i; i = e[i].nx) {
      pos = e[i].e;
      s1 -= a[pos];
      s2 += (r[pos] - pos + 1LL) * a[pos];
    }
    for (int i = head[L][1]; i; i = e[i].nx) {
      pos = e[i].e;
      s2 += (pos - l[pos] + 1LL) * a[pos];
      s1 -= a[pos];
    }
    for (int i = head[L][2]; i; i = e[i].nx) {
      pos = e[i].e;
      s2 -= (r[pos] - l[pos] + 2LL) * a[pos];
      s1 += a[pos];
    }
    for (int i = head[L][3]; i; i = e[i].nx) {
      pos = e[i].e;
      s1 -= a[pos];
      s2 += (pos - l[pos] + 1LL) * a[pos];
    }
    for (int i = head[L][4]; i; i = e[i].nx) {
      pos = e[i].e;
      s2 += (r[pos] - pos + 1LL) * a[pos];
      s1 -= a[pos];
    }
    for (int i = head[L][5]; i; i = e[i].nx) {
      pos = e[i].e;
      s2 -= (r[pos] - l[pos] + 2LL) * a[pos];
      s1 += a[pos];
    }
    ans[L] = 1.0 * (s1 * L + s2) / (n - L + 1);
  }
  scanf("%d", &m);
  while (m--) {
    scanf("%d", &k);
    printf("%.10f\n", ans[k]);
  }
}
