#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int m;
  cin >> m;
  vector<int> b(m);
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  int M = -1, cur = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (b[j] % a[i]) continue;
      int x = b[j] / a[i];
      if (x > M) {
        M = x;
        cur = 1;
      } else if (x == M)
        ++cur;
    }
  }
  cout << cur;
  return 0;
}
