#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int main() { int N; cin >> N; vector L(N); for (int i = 0; i < N; i++) cin >> L[i]; int Q; cin >> Q; vector K(Q); for (int j = 0; j < Q; j++) cin >> K[j]; priority_queue, greater> pq; for (int i = 0; i < N; i++) { for (int k = 1; k <= 500000; k++) { double x = (double)L[i] / k; if (pq.size() == 500000) { if (x <= pq.top()) break; else pq.pop(); } pq.push((double)L[i] / k); } } vector a(500001); for (int i = 500000; i >= 1; i--) { a[i] = pq.top(); pq.pop(); } for (int j = 0; j < Q; j++) cout << a[K[j]] << endl; }