Vasya's bicycle chain drive consists of two parts: n stars are attached to the pedal axle, m stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation.

We know that the i-th star on the pedal axle has ai (0 < a1 < a2 < ... < an) teeth, and the j-th star on the rear wheel axle has bj (0 < b1 < b2 < ... < bm) teeth. Any pair (i, j) (1 ≤ i ≤ n; 1 ≤ j ≤ m) is called a gear and sets the indexes of stars to which the chain is currently attached. Gear (i, j) has a gear ratio, equal to the value <image>.

Since Vasya likes integers, he wants to find such gears (i, j), that their ratios are integers. On the other hand, Vasya likes fast driving, so among all "integer" gears (i, j) he wants to choose a gear with the maximum ratio. Help him to find the number of such gears.

In the problem, fraction <image> denotes division in real numbers, that is, no rounding is performed.

Input

The first input line contains integer n (1 ≤ n ≤ 50) — the number of stars on the bicycle's pedal axle. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 104) in the order of strict increasing.

The third input line contains integer m (1 ≤ m ≤ 50) — the number of stars on the rear wheel axle. The fourth line contains m integers b1, b2, ..., bm (1 ≤ bi ≤ 104) in the order of strict increasing.

It is guaranteed that there exists at least one gear (i, j), that its gear ratio is an integer. The numbers on the lines are separated by spaces.

Output

Print the number of "integer" gears with the maximum ratio among all "integer" gears.

Examples

Input

2
4 5
3
12 13 15


Output

2


Input

4
1 2 3 4
5
10 11 12 13 14


Output

1

Note

In the first sample the maximum "integer" gear ratio equals 3. There are two gears that have such gear ratio. For one of them a1 = 4, b1 = 12, and for the other a2 = 5, b3 = 15.
//package CodeForces.Ladder.LessThan1300;

import java.util.*;
import java.lang.*;
import java.io.*;

public class BicycleChain {
    static BufferedReader input;
    static BufferedWriter output;

    private static int getAnswer(int n, int m, int[] a, int[] b) {
        HashMap<Integer, Integer> map = new HashMap<>();
        int maxV = -1;
        for (int ai : a) {
            for (int bi : b) {
                int c = bi/ai;
                if(bi%ai==0){
                    int freq = 0;
                    if(map.containsKey(c))
                        freq = map.get(c);
                    freq++;
                    map.put(c, freq);
                    if(c>maxV){
                        maxV = c;
                    }
                }
            }
        }
        return map.get(maxV);
    }

    public static void main(String[] args) throws Exception {
        onStart();
        int n = Integer.parseInt(input.readLine().trim());
        StringTokenizer st1 = new StringTokenizer(input.readLine());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(st1.nextToken());
        }
        int m = Integer.parseInt(input.readLine().trim());
        StringTokenizer st2 = new StringTokenizer(input.readLine());
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = Integer.parseInt(st2.nextToken());
        }
        output.write(getAnswer(n, m, a, b) + "\n");
        onStop();
    }


    // Don't touch these...
    private static void onStart() throws IOException {
        if (isOnlineJudge()) {
            input = new BufferedReader(new InputStreamReader(System.in));
            output = new BufferedWriter(new OutputStreamWriter(System.out));
        } else {
            input = new BufferedReader(new FileReader("input.txt"));
            output = new BufferedWriter(new FileWriter("output.txt"));
        }
    }

    private static void onStop() throws IOException {
        output.flush();
        if (!isOnlineJudge()) {
            BufferedReader output = new BufferedReader(new FileReader("output.txt"));
            BufferedReader answer = new BufferedReader(new FileReader("answer.txt"));
            StringBuilder outFile = new StringBuilder();
            StringBuilder ansFile = new StringBuilder();
            String temp;
            while ((temp = output.readLine()) != null) {
                outFile.append(temp);
            }
            while ((temp = answer.readLine()) != null) {
                ansFile.append(temp);
            }
            if (outFile.toString().equals(ansFile.toString())) {
                System.out.println("Test Cases Passed!!!");
            } else {
                System.out.println("Failed...");
            }
        }
    }

    private static boolean isOnlineJudge() {
        if (System.getProperty("ONLINE_JUDGE") != null)
            return true;
        try {
            System.getenv("USERNAME");
            return false;
        } catch (Exception e) {
            return true;
        }
    }
}