#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, flag = 0;
  vector<long double> v;
  scanf("%d", &n);
  long double *a = new long double[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  scanf("%d", &m);
  long double *b = new long double[m];
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  int count = 1;
  for (i = 0; i < n; i++) {
    for (j = m - 1; j >= 0; j--) {
      long double store = b[j] / a[i];
      if (floorl(store) == ceill(store)) {
        v.push_back(store);
        break;
      }
    }
  }
  sort(v.begin(), v.end(), greater<long double>());
  for (i = 1; i < v.size(); i++) {
    if (v[i] == v[0]) count++;
  }
  printf("%d\n", count);
  return 0;
}
