#include <bits/stdc++.h>
struct max {
  int num, much;
} max;
int a[55], b[55];
int main() {
  int i, an, bn;
  max.num = -1, max.much = 0;
  scanf("%d", &an);
  for (i = 0; i < an; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &bn);
  for (i = 0; i < bn; i++) {
    scanf("%d", &b[i]);
  }
  for (i = 0; i < an; i++) {
    for (int j = 0; j < bn; j++) {
      if (b[j] % a[i] == 0) {
        if (b[j] / a[i] > max.num) {
          max.num = b[j] / a[i];
          max.much = 1;
        } else if (b[j] / a[i] == max.num) {
          max.much++;
        }
      }
    }
  }
  printf("%d\n", max.much);
  return 0;
}
