#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  cin >> m;
  int arr2[m];
  for (int i = 0; i < m; i++) cin >> arr2[i];
  int maxx = -1;
  int cnt = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++)
      if (arr2[i] % arr[j] == 0 && arr2[i] / arr[j] >= maxx)
        if (arr2[i] / arr[j] == maxx)
          cnt++;
        else
          maxx = arr2[i] / arr[j], cnt = 1;
  cout << cnt;
  return 0;
}
