#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m, a[51] = {0}, b, i, j;
  vector<long> d;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> b;
    for (j = 0; j < n; j++)
      if (b % a[j] == 0) d.push_back(b / a[j]);
  }
  sort(d.begin(), d.end());
  long s = 1;
  for (j = d.size() - 2; j >= 0 && d[j] == d[j + 1]; j--) ++s;
  cout << s;
  return 0;
}
