#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  vector<int> avals, bvals;
  int maxval = -1, maxcnt = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    avals.push_back(a);
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int b;
    scanf("%d", &b);
    bvals.push_back(b);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      int a = avals[i], b = bvals[j];
      if (b % a == 0) {
        if (b / a > maxval) {
          maxval = b / a;
          maxcnt = 1;
        } else if (b / a == maxval) {
          ++maxcnt;
        }
      }
    }
  }
  cout << maxcnt << endl;
  return 0;
}
