#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(double(-1));
const int inf = int(1e9);
int a[100], b[100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  int ans = 0, best = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[j] % a[i] == 0) {
        int cur = b[j] / a[i];
        if (cur > best) {
          best = cur;
          ans = 1;
        } else {
          if (cur == best) {
            ans++;
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
