#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, maxi = 0, cnt = 0;
  double div;
  cin >> n;
  double a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  double b[m];
  for (int i = 0; i < m; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      div = b[j] / a[i];
      if (div > maxi && floor(div) == div) {
        maxi = div;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      div = b[j] / a[i];
      if (div == maxi && floor(div) == div) {
        cnt++;
      }
    }
  }
  cout << cnt;
}
