#include <bits/stdc++.h>
using namespace std;
long long int n, p, mx = -1, c, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  long long int b[m];
  for (long long int i = 0; i < m; i++) cin >> b[i];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      p = 0;
      if (b[j] % a[i] == 0) p = b[j] / a[i];
      if (p > mx) {
        mx = p;
        c = 1;
      } else if (p == mx)
        c++;
    }
  }
  cout << c << endl;
  return 0;
}
