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