ll@R,@N,H[R+1]{};rep(N)H[rd_ll()+1]++;rep(i,1,R)H[i+1]+=H[i];ll@Q;REP(Q){ll@l,@r;r-=Q=l/R*R;wt(r/R*H[R]-H[l-Q]+H[r%R+1]);}