Given a sequence of integers a1, ..., an and q queries x1, ..., xq on it. For each query xi you have to count the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and gcd(al, al + 1, ..., ar) = xi.

<image> is a greatest common divisor of v1, v2, ..., vn, that is equal to a largest positive integer that divides all vi.

Input

The first line of the input contains integer n, (1 ≤ n ≤ 105), denoting the length of the sequence. The next line contains n space separated integers a1, ..., an, (1 ≤ ai ≤ 109).

The third line of the input contains integer q, (1 ≤ q ≤ 3 × 105), denoting the number of queries. Then follows q lines, each contain an integer xi, (1 ≤ xi ≤ 109).

Output

For each query print the result in a separate line.

Examples

Input

3
2 6 3
5
1
2
3
4
6


Output

1
2
2
0
1


Input

7
10 20 3 15 1000 60 16
10
1
2
3
4
5
6
10
20
60
1000


Output

14
0
2
2
2
0
2
2
1
1
import java.io.*;
import java.util.*;
public class D{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		int n=sc.nextInt();
		int [] a=new int [n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		SparseTable st=new SparseTable(a);
		HashMap<Integer,Long> map=new HashMap<>();
		int q=sc.nextInt();
		int [] b=new int [q];
		for(int i=0;i<q;i++) {
			b[i]=sc.nextInt();
			map.put(b[i], 0L);
		}
		for(int i=0;i<n;i++) {
			int idx=i;
			while(true) {
				int g=st.query(i, idx);
				int start=idx+1,end=n-1,ans=n;
				while(start<=end) {
					int mid=(start+end)/2;
					if(st.query(i, mid)!=g) {
						ans=mid;
						end=mid-1;
					}else
						start=mid+1;
				}
				if(map.containsKey(g))
					map.put(g,map.get(g)+ans-idx);
				idx=ans;
				if(ans==n)
					break;
			}
		}
		for(int i=0;i<q;i++)
			pw.println(map.get(b[i]));
		pw.flush();
		pw.close();
    }
	
	static int gcd(int a,int b) {
		return b==0? a : gcd(b, a%b);
	}
	
	static class SparseTable {
		int [] logs;
		int [] a;
		int [][] st;
		//st[i][j] --> minimum of sub array starting at index i and of length 2^j
		SparseTable(int [] a){
			int n=a.length;
			this.a=a;
			int k=(int)Math.floor(Math.log(n)/Math.log(2))+1;
			st=new int [n][k];
			for(int i=0;i<n;i++)
				st[i][0]=a[i];
			//(1<<j)===(2^j)
			for(int j=1;(1<<j)<=n;j++)
				for(int i=0;i+(1<<j)-1<n;i++)
						st[i][j]=gcd(st[i+(1<<(j-1))][j-1],st[i][j-1]);
			logs=new int [n+1];
			int cur=0;
			int pow=1;
			for(int i=1;i<=n;i++) {
				if(2*pow<i) {
					pow*=2;
					cur++;
				}
				logs[i]=cur;
			}
		}
		int query(int i,int j){
			int k=logs[j-i+1];
			return gcd(st[i][k],st[j-(1<<k)+1][k]);
		}
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
} 