#include using namespace std; vector value; long long n, K, N; vector S, A; void update(int i, int x){ i += N - 1; value[i] += x; while (i > 0){ i = (i - 1)/2; value[i] = value[2*i + 1] + value[2*i + 2]; } } int query(int a, int b, int k, int l, int r){ if ( r <= a || b <= l ) return 0; if (a <= l && r <= b){ return value[k]; }else{ int c1 = query(a, b, 2*k + 1, l, (l + r)/2); int c2 = query(a, b, 2*k + 2, (l + r)/2, r); return c1 + c2; } } bool isOK(int index, int key){ if (key < S[index]) return true; else return false; } int binary_search(int key){ int ng = -1; int ok = n - K + 1; while (abs(ok - ng) > 1){ int mid = (ok + ng)/2; if(isOK(mid,key)) ok = mid; else ng = mid; } return ok; } int main(){ cin >> n >> K; N = 1; while (N < n) N *= 2; A.resize(n); S.assign(n - K + 1, 0); value = vector(2*N - 1, 0); for (int i = 0; i < n; ++i){ cin >> A[i]; update(i, A[i]); } int q; cin >> q; for (int i = 0; i <= n - K; ++i){ S[i] = query(i, i + K, 0, 0, N); } sort(S.begin(), S.end()); for (int j = 0; j < q; ++j){ int t; cin >> t; cout << binary_search(t) << endl; } }