#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(int i=0;i> R >> N; for(i=1;i<=N;i++){ ll x; cin >> x; a[x]=1; } for(i=1;i> Q; while(Q--){ ll l,r; cin >> l >> r; cout << r/R*N-(l-1)/R*N+a[r%R]-a[(l-1)%R] << endl; } return 0; }