#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[50], maximum[50], o = 0;
  int a1[50];
  int a2[50];
  int k = 0, maxi = INT_MIN;
  for (int i = 0; i < n; i++) cin >> a1[i];
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) cin >> a2[i];
  for (int i = 0; i < n; i++) {
    k = 0;
    for (int j = 0; j < m; j++) {
      if (a2[j] % a1[i] == 0) {
        arr[k] = a2[j] / a1[i];
        k++;
      }
    }
    maxi = INT_MIN;
    for (int l = 0; l < k; l++) {
      if (arr[l] > maxi) maxi = arr[l];
    }
    maximum[o] = maxi;
    o++;
  }
  maxi = INT_MIN;
  int countmax = 0;
  for (int i = 0; i < o; i++) {
    if (maximum[i] > maxi) maxi = maximum[i];
  }
  for (int i = 0; i < o; i++) {
    if (maximum[i] == maxi) countmax++;
  }
  cout << countmax;
}
