#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
int solution(int a[], int b[]) {
  int sol[100];
  int k = 0;
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      if (b[j] % a[i] == 0) {
        sol[k++] = b[j] / a[i];
        break;
      }
    }
  }
  int maxi = *max_element(sol, sol + k);
  int val = count(sol, sol + k, maxi);
  return val;
}
int main() {
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> m;
  int b[m];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  cout << solution(a, b) << endl;
}
