from collections import defaultdict, deque, Counter #from functools import cache # import copy from itertools import combinations, permutations, product, accumulate, groupby, chain #from more_itertools import distinct_permutations from heapq import heapify, heappop, heappush, heappushpop import math import bisect from pprint import pprint from random import randint, shuffle, randrange #from sortedcontainers import SortedSet, SortedList, SortedDict import sys # sys.setrecursionlimit(2000000) input = lambda: sys.stdin.readline().rstrip('\n') inf = float('inf') mod1 = 10**9+7 mod2 = 998244353 def ceil_div(x, y): return -(-x//y) ################################################# R, N = map(int, input().split()) A = list(map(int, input().split())) A.sort() A = A+[R+a for a in A] Q = int(input()) for _ in range(Q): l, r = map(int, input().split()) r += 1 p = (r-l)//R r -= p*R q = l//R l -= q*R; r -= q*R ans = N*p ans += bisect.bisect_left(A, r)-bisect.bisect_left(A, l) print(ans)