#include <bits/stdc++.h>
using namespace std;
int le[1000005], ri[1000005], q[1000005];
long long a[1000005], b[1000005];
double ans[1000005];
int main() {
  int n, i, m;
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) scanf("%I64d", &a[i]);
    q[0] = 0;
    a[0] = -1;
    int top = 0;
    for (i = 1; i <= n; i++) {
      while (a[i] < a[q[top]]) top--;
      le[i] = i - q[top];
      q[++top] = i;
    }
    q[0] = n + 1;
    a[n + 1] = -1, top = 0;
    for (i = n; i >= 1; i--) {
      while (a[i] <= a[q[top]]) top--;
      ri[i] = q[top] - i;
      q[++top] = i;
    }
    memset(b, 0, sizeof(b));
    for (i = 1; i <= n; i++) {
      b[1] += a[i];
      b[le[i] + 1] -= a[i];
      b[ri[i] + 1] -= a[i];
      b[le[i] + ri[i] + 1] += a[i];
    }
    double tot = 0, slope = 0;
    for (i = 1; i <= n; i++) {
      slope += b[i];
      tot += slope;
      ans[i] = tot / (n - i + 1);
    }
    scanf("%d", &m);
    while (m--) {
      scanf("%d", &i);
      printf("%.10lf\n", ans[i]);
    }
  }
  return 0;
}
