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