Debug

Each call increments every index divisible by the given jump; answer range-sum queries over the resulting array.

Medium5ArrayMathPrefix sumImplementationNo attempts yetTime limit3sMemory limit512 MB

Problem

Seán is debugging his own code. He first creates an array seq of NN integers and fills it with zeros. He then calls the following C++ function several times.

void something( int jump ) {
 int i = 0;
 while( i < N ) {
   seq[i] = seq[i] + 1;
   i = i + jump;
 }
}

The function adds 1 to every element whose index is a multiple of jump. Index 0 is a multiple of every jump, so seq[0] grows by 1 on every call.

Seán calls the function exactly KK times and passes X1,X2,,XKX_1, X_2, \dots, X_K in that order.

Once the calls are done, Seán picks QQ parts of the array he wants to check. Each part is given by its left bound LL and its right bound RR (LRL \le R). For each part, compute seq[L] + seq[L+1] + ... + seq[R].

Input

The first line contains the array size NN and the number of calls KK (1N1061 \le N \le 10^6, 1K1061 \le K \le 10^6).

The second line contains the KK arguments X1,X2,,XKX_1, X_2, \dots, X_K separated by spaces (1Xi<N1 \le X_i < N).

The third line contains the number of parts QQ (1Q1061 \le Q \le 10^6).

Each of the next QQ lines contains two integers LiL_i and RiR_i (0LiRi<N0 \le L_i \le R_i < N).

Output

Print QQ lines. Line ii holds the value of seq[L_i] + seq[L_i + 1] + ... + seq[R_i].