#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int a[1000005], l[1000005], r[1000005];
int M;
double T[1 << 21], TT[1 << 21];
void update(int l, int r, double x, double *T) {
  l = l + M - 1;
  r = r + M + 1;
  for (; l ^ r ^ 1; l >>= 1, r >>= 1) {
    if (~l & 1) T[l ^ 1] += x;
    if (r & 1) T[r ^ 1] += x;
  }
}
double query(int x, double *T) {
  double ans = 0;
  x = x + M;
  while (x >= 1) {
    ans += T[x];
    x >>= 1;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int(i) = 0; (i) < (int)(n); (i)++) scanf("%d", a + i + 1);
  priority_queue<pair<int, int>> q, q1;
  for (int i = n; i; i--) {
    int R = n + 1;
    while (!q.empty()) {
      auto pp = q.top();
      if (pp.first >= a[i])
        q.pop();
      else {
        R = pp.second;
        break;
      }
    }
    r[i] = R;
    q.push({a[i], i});
  }
  for (int i = 1; i <= n; i++) {
    int L = 0;
    while (!q1.empty()) {
      auto pp = q1.top();
      if (pp.first > a[i])
        q1.pop();
      else {
        L = pp.second;
        break;
      }
    }
    l[i] = L;
    q1.push({a[i], i});
  }
  for (M = 1; n + 2 > M; M <<= 1)
    ;
  for (int i = 1; i <= n; i++) {
    int L = i - l[i];
    int R = r[i] - i;
    if (R < L) swap(L, R);
    if (L >= 1) update(1, L, 1.0 * a[i], T);
    if (L + 1 <= R) update(L + 1, R, 1.0 * L * a[i], TT);
    if (R + 1 <= L + R - 1) {
      update(R + 1, L + R - 1, 1.0 * (L + R) * a[i], TT);
      update(R + 1, L + R - 1, -1.0 * a[i], T);
    }
  }
  scanf("%d", &m);
  while (m--) {
    scanf("%d", &k);
    double aa = query(k, TT) + query(k, T) * k;
    printf("%.10lf\n", aa / (n - k + 1));
  }
  return 0;
}
