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