#include #include #include using namespace std; int main(){ int n, k; cin >> n >> k; int r = 0; if((n - 1) % (k+1) == 0){ cout << "0" << endl; cout.flush(); }else{ r = (n-1) % (k+1); cout << r << endl; } while(true){ int v; cin >> v; if(v >= n) break; cout << (v - r + k) / (k+1) * (k+1) + r << endl; cout.flush(); } return 0; }