#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  int front[n];
  for (int i = 0; i < n; i++) {
    cin >> front[i];
  }
  cin >> m;
  int rear[m];
  for (int i = 0; i < m; i++) {
    cin >> rear[i];
  }
  int max = 0, ans = 0, div = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (rear[i] % front[j] == 0) {
        div = rear[i] / front[j];
        if (div > max) {
          max = div;
          ans = 0;
        }
        if (max == div) ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
