#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int arr1[t];
  vector<int> gear;
  for (int i = 0; i < t; i++) {
    cin >> arr1[i];
  }
  int n;
  cin >> n;
  int arr2[n];
  for (int i = 0; i < n; i++) {
    cin >> arr2[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < t; j++) {
      if (arr2[i] % arr1[j] == 0) gear.push_back(arr2[i] / arr1[j]);
    }
  }
  sort(gear.begin(), gear.end(), greater<int>());
  int count = 0;
  int who = 0;
  while (count < (gear.size() - 1) && (gear.at(count) == gear.at(count + 1))) {
    who++;
    count++;
  }
  cout << who + 1 << endl;
}
