#include <bits/stdc++.h>
long n, i, t, u, v, x, T;
const long Max = 1000010;
long a[Max], l[Max], r[Max], line[Max];
double p[Max], ans[Max], tot;
long min(long x, long y) { return x < y ? x : y; }
int main() {
  scanf("%ld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%ld", &a[i]);
    while (a[i] < a[line[t]]) t--;
    l[i] = line[t];
    line[++t] = i;
  }
  line[t = 0] = n + 1;
  for (i = n; i; i--) {
    while (a[i] <= a[line[t]]) t--;
    r[i] = line[t];
    line[++t] = i;
  }
  for (i = 1; i <= n; i++) {
    u = min(i - l[i], r[i] - i);
    v = r[i] - l[i] + 1;
    p[1] += a[i];
    p[u + 1] -= a[i];
    p[v - u] -= a[i];
    p[v] += a[i];
  }
  for (i = 1; i <= n; i++) ans[i] = ans[i - 1] + (tot += p[i]);
  for (scanf("%ld", &T); T; T--) {
    scanf("%ld", &x);
    printf("%0.16lf\n", ans[x] / double(n - x + 1));
  }
  return 0;
}
