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