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