Problem: 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

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastReader in = new FastReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    DCGCDSSQ solver = new DCGCDSSQ();
    solver.solve(1, in, out);
    out.close();
  }

  static class DCGCDSSQ {

    int[][] gcd;
    final int MAXK = 18;
    int n;
    int[] arr;
    int[] log;

    void build() {
      log = new int[n + 1];
      for (int i = 2; i <= n; ++i) {
        log[i] = log[i >> 1] + 1;
      }

      gcd = new int[n + 1][MAXK];
      for (int i = 0; i < n; ++i) {
        gcd[i][0] = arr[i];
      }
      for (int j = 1; j < MAXK; ++j) {
        for (int i = 0; i + (1 << j) <= n; ++i) {
          gcd[i][j] = IntMath.gcd(gcd[i][j - 1], gcd[i + (1 << (j - 1))][j - 1]);
        }
      }
    }

    int gcd(int l, int r) {
      if (r < l) {
        return 0;
      }
      int j = log[r - l + 1];
      return IntMath.gcd(gcd[l][j], gcd[r - (1 << j) + 1][j]);
    }

    public void solve(int testNumber, FastReader in, PrintWriter out) {
      n = in.nextInt();
      arr = in.nextIntArray(n);
      build();
      LongCountingMap<Integer> count = new LongCountingMap<>();
      for (int left = 0; left < n; left++) {
        int right = left;
        while (right < n) {
          int cur = gcd(left, right);
          int lo = right, hi = n - 1;
          int match = right;
          while (lo <= hi) {
            int mid = (lo + hi) >> 1;
            if (gcd(left, mid) == cur) {
              match = mid;
              lo = mid + 1;
            } else {
              hi = mid - 1;
            }
          }
          count.incrementBy(cur, match - right + 1);
          right = match + 1;
        }
      }

      int q = in.nextInt();
      while (q-- > 0) {
        int target = in.nextInt();
        out.println(count.getOrDefault(target, 0L));
      }
    }

  }

  static class FastReader implements FastIO {

    BufferedReader reader;
    StringTokenizer st;

    public FastReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      st = null;
    }

    public String next() {
      while (st == null || !st.hasMoreTokens()) {
        try {
          String line = reader.readLine();
          if (line == null) {
            return null;
          }
          st = new StringTokenizer(line);
        } catch (Exception e) {
          throw new RuntimeException();
        }
      }
      return st.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public int[] nextIntArray(int n) {
      int[] arr = new int[n];
      int i = 0;
      while (i < n) {
        arr[i++] = nextInt();
      }
      return arr;
    }

  }

  static interface FastIO {

  }

  static class LongCountingMap<T> {

    private Map<T, Long> map;

    public LongCountingMap() {
      map = new HashMap<>();
    }

    public void incrementBy(T key, Integer step) {
      map.put(key, map.getOrDefault(key, 0L) + step);
    }

    public Long getOrDefault(T value, Long def) {
      return map.getOrDefault(value, def);
    }

    public String toString() {
      return "CountingMap{" +
          "map=" + map +
          '}';
    }

  }

  static class IntMath {

    public static int gcd(int a, int b) {
      if (b != 0) {
        return gcd(b, a % b);
      }
      return a;
    }

  }
}