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