#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void inp(T &any) {
  cin >> any;
}
template <typename T, typename... U>
inline void inp(T &a, U &...b) {
  cin >> a;
  inp(b...);
}
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
  for (auto &x : a) in >> x;
  return in;
}
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T, U> &a) {
  in >> a.first >> a.second;
  return in;
}
void solve(long long int &T) {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  cin >> a;
  long long int m;
  cin >> m;
  vector<long long int> b(m);
  cin >> b;
  long long int mx = 0, ans = 0;
  for (long long int i = (0); i < (n); i++) {
    for (long long int j = (0); j < (m); j++) {
      if (b[j] % a[i] == 0) {
        if (b[j] / a[i] > mx) {
          mx = b[j] / a[i];
          ans = 1;
        } else if (b[j] / a[i] == mx) {
          ans++;
        }
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  for (long long int Case = (1); Case < (t + 1); Case++) {
    if (0) cerr << "Case #" << Case << "\n";
    solve(Case);
  }
  return 0;
}
