#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
int n, m;
int a[N], stk[N], l[N], r[N];
int tp;
long long ans[N];
long long s[N << 2];
void pushdown(int rt) {
  s[(rt << 1)] += s[rt];
  s[(rt << 1 | 1)] += s[rt];
  s[rt] = 0;
}
void update(int L, int R, int val, int l, int r, int rt) {
  if (L <= l && r <= R) {
    s[rt] += val;
    return;
  }
  pushdown(rt);
  if (L <= ((l + r) >> 1)) update(L, R, val, l, ((l + r) >> 1), (rt << 1));
  if (((l + r) >> 1) < R)
    update(L, R, val, ((l + r) >> 1) + 1, r, (rt << 1 | 1));
}
long long query(int k, int l, int r, int rt) {
  if (l == r) {
    return s[rt];
  }
  pushdown(rt);
  if (k <= ((l + r) >> 1)) return query(k, l, ((l + r) >> 1), (rt << 1));
  if (((l + r) >> 1) < k) return query(k, ((l + r) >> 1) + 1, r, (rt << 1 | 1));
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  stk[0] = n;
  tp = 1;
  for (int i = n - 1; i > -1; i--) {
    while (a[i] <= a[stk[tp - 1]]) tp--;
    r[i] = stk[tp - 1] - i;
    stk[tp++] = i;
  }
  stk[0] = n;
  tp = 1;
  for (int i = 0; i < n; i++) {
    while (a[i] < a[stk[tp - 1]]) tp--;
    l[i] = (stk[tp - 1] == n ? i + 1 : i - stk[tp - 1]);
    stk[tp++] = i;
  }
  for (int i = 0; i < n; i++) {
    update(1, ((l[i]) < (r[i]) ? (l[i]) : (r[i])), (long long)a[i], 1, n + 5,
           1);
    update(((l[i]) > (r[i]) ? (l[i]) : (r[i])) + 1, l[i] + r[i],
           (long long)-a[i], 1, n + 5, 1);
  }
  ans[0] = 0;
  for (int i = 1; i <= n; i++) {
    ans[i] = ans[i - 1] + query(i, 1, n + 5, 1);
  }
  scanf("%d", &m);
  int k;
  while (m--) {
    scanf("%d", &k);
    printf("%.10lf\n", 1.0 * ans[k] / (double)(n - k + 1));
  }
  return 0;
}
