#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100030;
const long long MODD = 1000000009;
int B[MAX_N], A[MAX_N];
void do_case() {
  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 N = 0, D = 1, ctr = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (B[j] % A[i]) continue;
      if (B[j] * D > A[i] * N) {
        ctr = 0;
        N = B[j];
        D = A[i];
      }
      if (B[j] * D == A[i] * N) ctr++;
    }
  cout << ctr << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  do_case();
  return 0;
}
