#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, temp, max_div = -1, counter = 1;
  cin >> a;
  int arr[a];
  for (int i = 0; i < a; i++) cin >> arr[i];
  cin >> b;
  for (int i = 0; i < b; i++) {
    cin >> temp;
    for (int j = 0; j < a; j++) {
      if (temp % arr[j] == 0) {
        if (temp / arr[j] == max_div) counter++;
        if (temp / arr[j] > max_div) {
          max_div = temp / arr[j];
          counter = 1;
        }
      }
    }
  }
  cout << counter;
  return 0;
}
