#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  double ans[3000], a[3000], b[3000];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf", &a[i]);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) scanf("%lf", &b[i]);
  int k = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) ans[k++] = b[j] / a[i];
  int cnt = 0;
  double mx = 0;
  for (int i = 0; i < k; i++)
    if (ans[i] == (int)ans[i] && ans[i] == mx)
      cnt++;
    else if (ans[i] == (int)ans[i] && ans[i] > mx) {
      mx = ans[i];
      cnt = 1;
    }
  printf("%d\n", cnt);
  return 0;
}
