#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long exp(long long a, long long b) {
  if (b == 0) return 1;
  long long res = exp(a, b / 2);
  if (b % 2)
    return res * res * a;
  else
    return res * res;
}
int prime(long long x) {
  if (x % 2 == 0)
    return 0;
  else {
    for (int i = 3; i * i <= x; i += 2) {
      if (x % i == 0) return 0;
    }
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m, k;
  map<int, int> ma;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  cin >> m;
  int brr[m];
  for (int i = 0; i < m; i++) cin >> brr[i];
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      if (brr[j] % arr[i] == 0) {
        k = brr[j] / arr[i];
        if (ma.find(k) == ma.end())
          ma.insert({k, 1});
        else
          ma[k]++;
      }
    }
  }
  map<int, int>::iterator it;
  it = ma.end();
  it--;
  cout << it->second << "\n";
  return 0;
}
