#include <bits/stdc++.h>
using namespace std;
int n;
const int MAXN = 1000010;
long long tt[MAXN], tt2[MAXN];
long long ta[MAXN];
int r[MAXN], a[MAXN];
bool cmp(int x, int y) { return ta[x] < ta[y]; }
int read(int x, int id) {
  long long ans;
  if (id == 0)
    ans = n;
  else
    ans = -1;
  while (x > 0) {
    if (id == 0)
      ans = min(ans, tt[x]);
    else
      ans = max(ans, tt[x]);
    x -= x & -x;
  }
  return (int)ans;
}
void update(int x, int val, int id) {
  while (x < MAXN) {
    if (id == 0)
      tt[x] = min(tt[x], (long long)val);
    else
      tt[x] = max(tt[x], (long long)val);
    x += x & -x;
  }
}
int l[MAXN];
void update(long long *tt, int x, long long val) {
  while (x < MAXN) {
    tt[x] += val;
    x += x & -x;
  }
}
long long read(long long *tt, int x) {
  long long ans = 0;
  while (x > 0) {
    ans += tt[x];
    x -= x & -x;
  }
  return ans;
}
int main() {
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) scanf("%I64d", &ta[i]);
    for (int i = 0; i < n; i++) r[i] = i;
    sort(r, r + n, cmp);
    int now = 0;
    for (int i = 0; i < n; i++) {
      if (i == 0 || ta[r[i]] != ta[r[i - 1]]) now++;
      a[r[i]] = now;
    }
    memset(tt, -1, sizeof(tt));
    for (int i = 0; i < n; i++) {
      l[i] = read(a[i], 1);
      update(a[i], i, 1);
    }
    for (int i = 0; i <= now; i++) tt[i] = n;
    for (int i = n - 1; i >= 0; i--) {
      r[i] = read(a[i] - 1, 0);
      update(a[i], i, 0);
    }
    memset(tt, 0, sizeof(tt));
    memset(tt2, 0, sizeof(tt2));
    for (int i = 0; i < n; i++) {
      int Llen, Rlen, len;
      Llen = i - l[i];
      Rlen = r[i] - i;
      len = Llen + Rlen - 1;
      if (Llen < Rlen) swap(Llen, Rlen);
      update(tt, Llen, ta[i] * (len + 1));
      update(tt, len + 1, -ta[i] * (len + 1));
      update(tt2, Llen, -ta[i]);
      update(tt2, len + 1, ta[i]);
      if (Rlen <= Llen - 1) {
        update(tt, Rlen, Rlen * ta[i]);
        update(tt, Llen, -(Rlen)*ta[i]);
      }
      if (Rlen - 1 >= 1) {
        update(tt2, 1, ta[i]);
        update(tt2, Rlen, -ta[i]);
      }
    }
    int m;
    scanf("%d", &m);
    while (m--) {
      int num;
      scanf("%d", &num);
      long long num1 = read(tt, num);
      long long num2 = read(tt2, num);
      long long ans = num1 + num2 * num;
      printf("%.15f\n", ans * 1.0 / (n + 1 - num));
    }
    puts("");
  }
  return 0;
}
