function Main(INPUT){ const input=INPUT.split("\n"); const [R,N] = input[0].split(" ").map(_=>parseInt(_)); let count = input[1].split(" ").map(_=>parseInt(_)); count = count.sort((a,b)=>a-b); const Q=parseInt(input[2]); for(let i=0;iparseInt(_)); l--; let [cl,cr]=[l%R, r%R]; let[lok,lng,rok,rng]=[-1,N,-1,N]; while(lng>lok+1){ let mid = Math.floor((lng+lok)/2); if(count[mid]<=cl){ lok=mid; } else{ lng=mid; } } while(rng>rok+1){ let mid = Math.floor((rng+rok)/2); if(count[mid]<=cr){ rok=mid; } else{ rng=mid; } } console.log(N*Math.floor(r/R)+rng - N*Math.floor(l/R)-lng); } } Main(require("fs").readFileSync("/dev/stdin", "utf8"));