#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a, b;
  for (int i = 0; i < n; i++) {
    int u;
    cin >> u;
    a.push_back(u);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int u;
    cin >> u;
    b.push_back(u);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(), greater<int>());
  int count = 0, max = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[j] % a[i] == 0 && b[j] / a[i] > max) {
        max = b[j] / a[i];
        count = 0;
        count++;
        continue;
      } else if (b[j] / a[i] < max) {
        break;
      }
      if (b[j] % a[i] == 0 && max == b[j] / a[i]) {
        count++;
      }
    }
  }
  cout << count;
  return 0;
}
