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