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.
#include<cstdio>
#include<cmath>
#define ll long long int
#define num 10000005
#define big 10000000
#define n_type unsigned ll

int a[num],n,m,r,l,primes[num];

bool isPrime(n_type n)
{
	if (n==2 || n==3 || n==5|| n==7) return true;
	if (n<=1 || !(n&1))return 0;
	int hold=ceil(sqrt(n));
	for (int i=3;i<=hold;i+=2) if (n%i == 0) return false;
	return true;
}

void factors(int n)
{
	if (n<2)
		return;
	if ((n&1)==0)
	{
		while ((n&1)==0)n/=2;
		primes[2]++;
	}
    for (int z=3;z*z<= n;z+=2)
    	if (n%z==0)
    	{
    		while (n%z==0)n/=z;
    		primes[z]++;
		}
	if (n>1) primes[n]++;
}
int main ()
{
//	freopen("test.txt","r",stdin);
	scanf("%d",&n);
	for (int i=0;i<n;i++)scanf("%d",&a[i]);
	for (int i=0;i<n;i++)factors(a[i]);
	for (int i=1;i<num;i++)primes[i]+=primes[i-1];
	scanf("%d",&m);
	for (int i=0;i<m;i++)
	{
		scanf("%d %d",&l,&r);
		if (l>big) l= big;
		if (r>big) r =big;
		printf("%d ",primes[r]-primes[l-1]);
	}
	fclose(stdin);
	return 0;
}
