#include <bits/stdc++.h>
using namespace std;
int i[105] = {0};
int j[105] = {0};
int f[100005] = {0};
int main() {
  int n, m;
  cin >> n;
  for (int a = 1; a <= n; a++) cin >> i[a];
  cin >> m;
  for (int a = 1; a <= m; a++) cin >> j[a];
  for (int a = 1; a <= m; a++) {
    for (int b = 1; b <= n; b++) {
      if (j[a] % i[b] == 0) {
        f[j[a] / i[b]]++;
      }
    }
  }
  int Themax = 0;
  for (int a = 10000; a >= 1; a--) {
    if (f[a] != 0) {
      cout << f[a] << endl;
      break;
    }
  }
  return 0;
}
