#include <bits/stdc++.h>
int main() {
  int n, i, j, max = 0, count;
  scanf("%d", &n);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int m;
  scanf("%d", &m);
  int b[m];
  for (i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if ((b[j] % a[i]) == 0) {
        if ((b[j] / a[i]) > max) {
          max = (b[j] / a[i]);
          count = 0;
        }
        if ((b[j] / a[i]) == max) {
          count++;
        }
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
