#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0, i, max, num, z;
  cin >> n;
  int A[n];
  max = 0;
  for (i = 0; i < n; i++) {
    cin >> A[i];
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> num;
    z = 0;
    while (z < n && num % A[z] != 0) z++;
    if (z == n) continue;
    if (num / A[z] == max)
      ans++;
    else if (num / A[z] > max) {
      max = num / A[z];
      ans = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
