#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; i++) cin >> ar[i];
  cin >> m;
  int ar1[m];
  for (int i = 0; i < m; i++) cin >> ar1[i];
  int rat[n], c = 0;
  for (int i = 0; i < n; i++) {
    c = 0;
    for (int j = 0; j < m; j++) {
      if (ar1[j] % ar[i] == 0) {
        rat[i] = ar1[j] / ar[i];
        c = 1;
      }
    }
    if (!c) {
      rat[i] = 0;
    }
  }
  sort(rat, rat + n, greater<int>());
  c = 0;
  while (rat[c] == rat[0]) {
    c++;
  }
  cout << c;
}
