#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  int tmp, max = 0, veces = 0;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    A[i] = tmp;
  }
  cin >> m;
  vector<int> B(m);
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    B[i] = tmp;
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (B[i] % A[j] == 0 && B[i] / A[j] >= max) max = B[i] / A[j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (B[i] % A[j] == 0)
        if (B[i] / A[j] == max) veces++;
    }
  }
  cout << veces << endl;
}
