#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T abs(const T& x) {
  return x > 0 ? x : -x;
}
template <class T>
inline T sqr(const T& x) {
  return x * x;
}
template <class T>
inline string tostr(const T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const int inf = 1999999999;
const double pi = acos(-1.0);
const double eps = 1e-9;
inline char gc() {
  char c;
  while (isspace(c = getchar()))
    ;
  return c;
}
inline int gs(char* s) {
  fgets(s, 9999999, stdin);
  int l = strlen(s);
  while (l && isspace(s[l - 1])) s[--l] = 0;
  return l;
}
int a[10010];
int b[10010];
int ans[10010];
int main() {
  clock_t start = clock();
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int mx = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    mx = max(mx, b[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[j] % a[i] == 0) {
        int tmp = b[j] / a[i];
        ans[tmp]++;
      }
    }
  }
  for (int i = mx; i >= 0; i--) {
    if (ans[i] != 0) {
      cout << ans[i] << ('\n');
      break;
    }
  }
  return 0;
}
