#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[55], b[55], ans[5000] = {}, k = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  cin >> m;
  for (int i = 0; i < m; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (b[j] % a[i] == 0) {
        ans[k] = b[j] / a[i];
        k++;
      }
    }
  }
  sort(ans, ans + k);
  int c = 0;
  for (int i = k - 1; i >= 0; --i)
    if (ans[i] == ans[k - 1]) c++;
  cout << c;
  return 0;
}
