#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n;
  double a[n], ma = -1e9;
  long long int i, j, c = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> m;
  double b[m];
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (ceil(b[j] / a[i]) == floor(b[j] / a[i])) {
        if (b[j] / a[i] > ma) {
          ma = b[j] / a[i];
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (b[j] / a[i] == ma) c++;
    }
  }
  cout << c << endl;
}
