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