#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int m, n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  int b[m];
  for (int i = 0; i < m; i++) cin >> b[i];
  int max = -1;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int tmp = b[j] / a[i];
      if (b[j] % a[i] == 0) {
        if (tmp > max) {
          v.clear();
          max = tmp;
          v.push_back(tmp);
        } else if (tmp == max) {
          v.push_back(tmp);
        }
      }
    }
  }
  cout << v.size() << endl;
}
