#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[50], b[50];
  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 cnt = 0, d = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (b[j] % a[i] == 0) {
        if (b[j] / a[i] == d) {
          ++cnt;
        } else if (b[j] / a[i] > d) {
          d = b[j] / a[i];
          cnt = 1;
        }
      }
    }
  }
  cout << cnt;
  return 0;
}
