#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, count = 0, b;
  double max = 0, mas[10000];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> mas[i];
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> b;
    for (int j = 0; j < n; ++j) {
      if (b % (int)mas[j] == 0) {
        if (b / mas[j] > max) {
          max = b / mas[j];
          count = 1;
        } else if (abs(max - b / mas[j]) <= 0.000001)
          count++;
      }
    }
  }
  cout << count;
  return 0;
}
