#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  double a, b;
  vector<double> v1, v2, v3;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v1.push_back(a);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> b;
    v2.push_back(b);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      double ans = v2[j] / v1[i];
      if (ceil(v2[j] / v1[i]) == ans && floor(v2[j] / v1[i]) == ans)
        v3.push_back(ans);
    }
  }
  sort(v3.begin(), v3.end());
  int top = v3.back(), track = 0;
  vector<double>::reverse_iterator it;
  for (it = v3.rbegin(); it != v3.rend(); it++) {
    if (*it == top)
      track++;
    else
      break;
  }
  cout << track;
  return 0;
}
