#include <bits/stdc++.h>
using namespace std;
int a[60];
int b[60];
int main() {
  int n, m;
  int c;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &m);
  for (int j = 1; j <= m; j++) scanf("%d", &b[j]);
  int maxx = 0;
  int s = 0;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      if (b[i] % a[j] == 0) {
        c = b[i] / a[j];
        if (c > maxx) {
          maxx = c;
          s = 1;
        } else if (c == maxx) {
          s++;
        }
      }
    }
  printf("%d\n", s);
  return 0;
}
