#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c = 1;
  cin >> n;
  int N[n + 10];
  for (int i = 0; i < n; i++) {
    cin >> N[i];
  }
  cin >> m;
  int M[m + 10];
  for (int i = 0; i < m; i++) {
    cin >> M[i];
  }
  int mx = -1, r = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (M[j] % N[i] == 0) {
        r = 1;
        if (M[j] / N[i] > mx) {
          mx = M[j] / N[i];
          c = 1;
        } else {
          if (M[j] / N[i] == mx) {
            c++;
          }
        }
      }
    }
  }
  if (r == 0) {
    cout << 0 << endl;
  } else {
    cout << c << endl;
  }
}
