#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int m;
  cin >> m;
  vector<int> b(m);
  for (int i = 0; i < m; i++) cin >> b[i];
  int check = INT_MIN;
  unordered_map<int, int> ump;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      double test = (double)b[j] / a[i];
      if (ceil(test) == floor(test)) {
        check = max(check, (int)test);
        if (ump.find((int)test) == ump.end())
          ump[(int)test] = 1;
        else
          ump[(int)test]++;
      }
    }
  }
  cout << ump[check] << '\n';
  return 0;
}
