Recently, the bear started studying data structures and faced the following problem.

You are given a sequence of integers *x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, ..., *x*<sub class="lower-index">*n*</sub> of length *n* and *m* queries, each of them is characterized by two integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub>. Let's introduce *f*(*p*) to represent the number of such indexes *k*, that *x*<sub class="lower-index">*k*</sub> is divisible by *p*. The answer to the query *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> is the sum: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/5e448f6c1a0e40843cecdbbeb95970464626032f.png" style="max-width: 100.0%;max-height: 100.0%;"/>, where *S*(*l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub>) is a set of prime numbers from segment [*l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub>] (both borders are included in the segment).

Help the bear cope with the problem.
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">6</sup>). The second line contains *n* integers *x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, ..., *x*<sub class="lower-index">*n*</sub> (2 ≤ *x*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">7</sup>). The numbers are not necessarily distinct.

The third line contains integer *m* (1 ≤ *m* ≤ 50000). Each of the following *m* lines contains a pair of space-separated integers, *l*<sub class="lower-index">*i*</sub> and *r*<sub class="lower-index">*i*</sub> (2 ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ 2·10<sup class="upper-index">9</sup>) — the numbers that characterize the current query.
N=10**7
X=[True,True]+[False]*(N-1)
j=2
P=[0]*(N+1)
while j<N+1:
    if X[j]==False:
        X[j]=True
        P[j]=1
    else:
        j+=1
        continue
    for jj in range(j*j,N+1,j):
        X[jj]=True
    j+=1
n=int(input())
L=list(map(int,input().split()))
mm=max(L)
ans=[0]*(mm+1)

for j in range(mm+1):
    if P[j]==1:
        cp=0
        for x in L:
            if x%j==0:
                cp+=1
        ans[j]=cp
    else:
        continue
ss=0
dd=len(ans)
for hh in range(dd):
    ss+=ans[hh]
    ans[hh]=ss
m=int(input())
for kk in range(m):
    l,r=map(int,input().split())
    ans1=0
    if l>mm:
        ans1=0
    else:
        ans1=ans[min(r,mm)]-ans[l-1]

    print(ans1)