#include <bits/stdc++.h>
using namespace std;
int main() {
  int pa, wa, max = 0, maxs = 0;
  cin >> pa;
  float p[pa], aux;
  for (int i = 0; i < pa; i++) cin >> p[i];
  cin >> wa;
  float w[wa];
  for (int j = 0; j < wa; j++) cin >> w[j];
  for (int i = 0; i < pa; i++)
    for (int j = 0; j < wa; j++) {
      aux = w[j] / p[i] * 10000;
      while (aux >= 10000) aux -= 10000;
      if (aux == 0) {
        aux = w[j] / p[i];
        if (aux == max)
          maxs++;
        else if (aux > max) {
          max = aux;
          maxs = 1;
        }
      }
    }
  cout << maxs << endl;
  return 0;
}
