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