#include <bits/stdc++.h>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, a, b;
  cin >> n;
  vector<int> v, z, x;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    v.push_back(a);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> b;
    z.push_back(b);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (z[j] % v[i] == 0) {
        x.push_back(z[j] / v[i]);
      }
    }
  }
  sort(x.begin(), x.end());
  long long c = 1;
  for (int i = x.size() - 2; i >= 0; i--) {
    if (x[i] == x.back()) {
      c = c + 1;
    }
  }
  cout << c;
  return 0;
}
