#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647, maxN = 50 + 10, maxM = 50 + 10;
int N, M;
int A[maxN], B[maxM];
void setIO(string name) {
  string in = name + ".in";
  string out = name + ".out";
  freopen(in.c_str(), "r", stdin);
  freopen(out.c_str(), "w", stdout);
}
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]);
  int ans = -INF, cnt = 0;
  for (int i = 0; i < M; ++i)
    for (int j = 0; j < N; ++j)
      if (B[i] % A[j] == 0) {
        if (B[i] / A[j] > ans)
          ans = B[i] / A[j], cnt = 1;
        else if (B[i] / A[j] == ans)
          ++cnt;
      }
  printf("%d\n", cnt);
  return 0;
}
