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