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.
INF = 2023456789
n = int(input())
v = list(map(int,input().split()))
w = []
minl,maxr = INF, -1
m = int(input())
for i in range(m):
	l,r = map(int,input().split())
	w.append((l,r))
	minl = min(minl,l)
	maxr = max(maxr,r)

maxpr = min(maxr,5000047)
pr = [True for i in range(maxpr+1)]
pr[0],pr[1] = False,False
i = 2
while i*i <= maxpr:
	if pr[i]:
		for j in range(i*i,maxpr+1,i):
			pr[j] = False
	i+=1

minl-=1
xx = [0 for i in range(maxpr-minl+1)]
for i in range(minl,maxpr+1):
	if not pr[i]: continue
	j = 0
	while j < len(v):
		if v[j]%i == 0:
			xx[i-minl]+=1
			v[j]/=i
		if v[j] < i :
			v[j],v[len(v)-1] = v[len(v)-1],v[j]
			v.pop()
		else: j+=1
for i in range(1,len(xx)):
	xx[i] += xx[i-1]
for l,r in w:
	r = min(r,maxpr)
	r-=minl
	l-=minl
	print(xx[r]-xx[l-1])
