Bayan 2015 Contest Warm Up
D
CGCDSSQ
Codeforces
2000
原题
← CE →
翻译中…

Given a sequence of integers $*a*_{1}, ..., *a*_{*n*}$ and $*q*$ queries $*x*_{1}, ..., *x*_{*q*}$ on it. For each query $*x*_{*i*}$ you have to count the number of pairs $(*l*, *r*)$ such that $1 ≤ *l* ≤ *r* ≤ *n*$ and $*gcd*(*a*_{*l*}, *a*_{*l* + 1}, ..., *a*_{*r*}) = *x*_{*i*}$.

翻译中…

image is a greatest common divisor of $*v*_{1}, *v*_{2}, ..., *v*_{*n*}$, that is equal to a largest positive integer that divides all $*v*_{*i*}$.

翻译中…

Input

翻译中…

The first line of the input contains integer $*n*$, ($1 ≤ *n* ≤ 10^{5}$), denoting the length of the sequence. The next line contains $*n*$ space separated integers $*a*_{1}, ..., *a*_{*n*}$, ($1 ≤ *a*_{*i*} ≤ 10^{9}$).

翻译中…

The third line of the input contains integer $*q*$, ($1 ≤ *q* ≤ 3 × 10^{5}$), denoting the number of queries. Then follows $*q*$ lines, each contain an integer $*x*_{*i*}$, ($1 ≤ *x*_{*i*} ≤ 10^{9}$).

翻译中…

Output

翻译中…

For each query print the result in a separate line.

翻译中…

样例

Input #1
3
2 6 3
5
1
2
3
4
6
Output #1
1
2
2
0
1
InputCopy OutputCopy
Input #2
7
10 20 3 15 1000 60 16
10
1
2
3
4
5
6
10
20
60
1000
Output #2
14
0
2
2
2
0
2
2
1
1
InputCopy OutputCopy
题目信息
题号
475D
时间限制
2 s
内存限制
256 MB
标签
暴力
数据结构
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。