#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> n;
  int arr1[n];
  for (int i = 0; i < n; i++) cin >> arr1[i];
  cin >> t;
  int arr2[t];
  for (int i = 0; i < t; i++) cin >> arr2[i];
  int highest_ratio = 0, count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < t; j++) {
      if (arr2[j] % arr1[i] == 0) {
        int k = arr2[j] / arr1[i];
        if (k > highest_ratio) {
          highest_ratio = k;
          count = 1;
        } else if (k == highest_ratio)
          count++;
      }
    }
  }
  cout << count;
  return 0;
}
