#include <bits/stdc++.h>
using namespace std;
const int M = 1e2 + 5;
int a[M], b[M], c[10000 + 5];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  memset(c, 0, sizeof(c));
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  for (int i = 0; i < m; i++) cin >> b[i];
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (gcd(a[i], b[j]) == a[i]) c[b[j] / a[i]]++;
    }
  for (int i = 10004; i >= 0; i--) {
    if (c[i] > 0) {
      cout << c[i] << endl;
      break;
    }
    if (i == 0) cout << "0" << endl;
  }
  return 0;
}
