#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T abs(T x) {
  return x < 0 ? -x : x;
}
const double EPS = 1e-9;
int n, m, a[55], b[55], mx, ans, x;
double cur;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) scanf("%d", b + i);
  mx = 0;
  ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      cur = (b[j] + 0.) / a[i];
      if (abs((int)cur - cur) < EPS) {
        x = (int)cur;
        if (x > mx) {
          mx = x;
          ans = 1;
        } else if (x == mx)
          ++ans;
      }
    }
  printf("%d", ans);
  return 0;
}
