#include <bits/stdc++.h>
using namespace std;
int N = 2e5 + 7;
void fuckily() {
  int n, m, b[10001] = {0}, t, p = 1;
  cin >> n;
  int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  for (long long int i = 0; i < m; i++) {
    cin >> t;
    for (long long int i = 0; i < n; i++) {
      if (t % a[i] == 0) {
        b[t / a[i]]++;
        p = max(t / a[i], p);
      }
    }
  }
  cout << b[p];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    fuckily();
  }
  return 0;
}
