#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
long long a[N], r[N], l[N];
long long s1[N], s2[N], k;
double ans[N];
int n, m;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  a[0] = a[n + 1] = -((long long)1 << 62);
  for (int i = n; i >= 1; i--) {
    if (a[i + 1] <= a[i])
      r[i] = i + 1;
    else
      for (int j = r[i + 1]; j <= n + 1; j = r[j])
        if (a[j] <= a[i]) {
          r[i] = j;
          break;
        }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] < a[i])
      l[i] = i - 1;
    else
      for (int j = l[i - 1]; j >= 0; j = l[j])
        if (a[j] < a[i]) {
          l[i] = j;
          break;
        }
  }
  for (int i = 1; i <= n; i++) {
    long long x = i - l[i], y = r[i] - i;
    if (x > y) swap(x, y);
    s1[1] += a[i];
    s1[x + 1] -= a[i];
    s2[x + 1] += x * a[i];
    s2[y + 1] -= x * a[i];
    s2[y + 1] += (x + y) * a[i];
    s2[x + y] -= (x + y) * a[i];
    s1[y + 1] -= a[i];
    s1[x + y] += a[i];
  }
  long long S1 = 0, S2 = 0;
  for (int i = 1; i <= n; i++) {
    S1 += s1[i];
    S2 += s2[i];
    ans[i] = (S1 * i + S2) * 1.0 / ((n - i + 1) * 1.0);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%lld", &k);
    printf("%.9lf\n", ans[k]);
  }
  return 0;
}
