#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int a[100], b[100];
int n, m, k = 0;
int d = 0.0;
int main() {
  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) d = max(d, b[j] / a[i]);
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (m); j++)
      if ((b[j] % a[i] == 0) && (b[j] / a[i] == d)) k++;
  cout << k;
  return 0;
}
