R,N=map(int,input().split()) A=list(map(int,input().split())) A.sort() from bisect import bisect_right def f(x): ans=N*(x//R) pos=x%R ans+=bisect_right(A,pos) return ans Q=int(input()) for _ in range(Q): l,r=map(int,input().split()) p=f(r)-f(l-1) print(p)