#include <bits/stdc++.h>
using namespace std;
int n, m, ans, arr[55], coun, maxi;
int main() {
  scanf("%d", &m);
  for (int i = 0; i < m; i++) scanf("%d", arr + i);
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &ans);
    for (int i = 0; i < m; i++) {
      if (ans % arr[i] == 0 && ans / arr[i] > maxi) {
        maxi = ans / arr[i];
        coun = 1;
      } else if (ans % arr[i] == 0 && ans / arr[i] == maxi)
        coun++;
    }
  }
  printf("%d\n", coun);
  return 0;
}
