#include <bits/stdc++.h>
using namespace std;
template <class T>
void dbs(string str, T t) {
  cerr << str << " : " << t << "\n";
}
template <class T, class... S>
void dbs(string str, T t, S... s) {
  int idx = str.find(',');
  cerr << str.substr(0, idx) << " : " << t << ",";
  dbs(str.substr(idx + 1), s...);
}
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class S, class T>
ostream& operator<<(ostream& os, const map<S, T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
void prc(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
const int N = 1000010;
const int M = 20;
int pos[N + 1][M + 1];
long long a[N + 1];
long long b[N + 1];
long long c[N + 1];
long long d[N + 1];
long long e[N + 1];
long long answer1[N + 1];
int n;
int minVal(int x, int y) { return a[x] < a[y] ? x : y; }
int query(int l, int r) {
  int k = log2(r - l + 1);
  return minVal(pos[l][k], pos[r - (1 << k) + 1][k]);
}
void calc() {
  for (int j = (int)(1); j <= (int)(M); j++) {
    for (int i = (int)(1); i <= (int)(N); i++) {
      if (i + (1 << j) <= n + 1) {
        pos[i][j] = minVal(pos[i][j - 1], pos[i + (1 << (j - 1))][j - 1]);
      }
    }
  }
}
void solve(int l, int r) {
  if (l > r) return;
  int getPos = query(l, r);
  int x = min(getPos - l + 1, r - getPos + 1);
  int y = max(getPos - l + 1, r - getPos + 1);
  int z = r - l + 1;
  b[1] += a[getPos], b[x + 1] -= a[getPos];
  c[x + 1] += a[getPos] * x, c[y + 1] -= a[getPos] * x;
  d[y + 1] += a[getPos], d[z + 1] -= a[getPos];
  e[y + 1] += a[getPos] * (z + 1), e[z + 1] -= a[getPos] * (z + 1);
  solve(l, getPos - 1);
  solve(getPos + 1, r);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = (int)(1); i <= (int)(n); i++) {
    int temp;
    cin >> temp;
    a[i] = temp;
    pos[i][0] = i;
  }
  calc();
  solve(1, n);
  for (int i = (int)(1); i <= (int)(n); i++) {
    b[i] += b[i - 1], c[i] += c[i - 1], d[i] += d[i - 1], e[i] += e[i - 1];
  }
  for (int i = (int)(1); i <= (int)(n); i++) {
    answer1[i] = b[i] * i + c[i] - d[i] * i + e[i];
  }
  int m;
  cin >> m;
  while (m--) {
    int k;
    cin >> k;
    cout << fixed << setprecision(10) << answer1[k] / (1.0 * (n - k + 1))
         << "\n";
  }
  return 0;
}
