#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, arr[1000], arr1[1000], flag[100000], store[10000];
  memset(flag, 0, sizeof flag);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> arr1[i];
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr1[j] % arr[i] == 0) {
        store[k++] = arr1[j] / arr[i];
        flag[store[k - 1]]++;
      }
    }
  }
  int maxx = 0, coun = 0;
  for (int i = 0; i < k; i++) {
    maxx = max(maxx, store[i]);
  }
  for (int i = 0; i < k; i++) {
    if (store[i] == maxx) coun++;
  }
  cout << coun << endl;
  return 0;
}
