#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int N[52], M[52];
  int best, cnt;
  map<int, int, greater<int> > C;
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> N[i];
  cin >> m;
  for (int j = 0; j < (m); ++j) cin >> M[j];
  for (int b = 0; b < (m); ++b) {
    for (int a = 0; a < (n); ++a) {
      if (M[b] % N[a] == 0) {
        C[M[b] / N[a]]++;
      }
    }
  }
  for (typeof((C).begin()) it = (C).begin(); it != (C).end(); ++it) {
    cout << it->second << endl;
    break;
  }
  return 0;
}
