#include <bits/stdc++.h>
using namespace std;
int A[51][51];
int main() {
  int n, m;
  scanf("%d", &n);
  vector<int> P(n, 0);
  for (int i = 0; i < n; i++) {
    scanf("%d", &P[i]);
  }
  scanf("%d", &m);
  vector<int> R(m, 0);
  for (int i = 0; i < m; i++) {
    scanf("%d", &R[i]);
  }
  int mx = 0, ans = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      int val = (R[i] + 0.0) / P[j];
      if (val < 0.0) break;
      if (abs(val * P[j] - R[i]) < 0.000001) {
        A[i][j] = val;
        mx = max(mx, val);
      }
    }
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++)
      if (A[i][j] == mx) ans++;
  printf("%d\n", ans);
  return 0;
}
