#include <bits/stdc++.h>
int main() {
  int n, a[50], i, j, m;
  int ans = 0, cur = -1;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", a + i);
  scanf("%d", &m);
  for (j = 0; j < m; j++) {
    int x;
    scanf("%d", &x);
    for (i = 0; i < n; i++)
      if (x % a[i] == 0)
        if (x / a[i] == cur)
          ans++;
        else if (x / a[i] > cur) {
          ans = 1;
          cur = x / a[i];
        }
  }
  printf("%d\n", ans);
  return 0;
}
