#include <bits/stdc++.h>
using namespace std;
int main() {
  int A[1000], B[1000];
  int N, M;
  while (cin >> N) {
    int ans = -1000000, Count = 0;
    for (int i = 0; i < N; i++) {
      cin >> A[i];
    }
    cin >> 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++) {
        if (B[j] % A[i] == 0) {
          if (ans < B[j] / A[i]) {
            ans = max(ans, B[j] / A[i]);
            Count = 0;
          } else if (ans == B[j] / A[i]) {
            Count++;
          }
        }
      }
    }
    cout << Count + 1 << endl;
  }
  return 0;
}
