#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m;
  int a[m];
  for (int i = 0; i < m; i++) cin >> a[i];
  cin >> n;
  int b[n];
  for (int i = 0; i < n; i++) cin >> b[i];
  int max1 = INT_MIN;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[i] % a[j] == 0 && b[i] / a[j] > max1) max1 = b[i] / a[j];
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[i] % a[j] == 0 && b[i] / a[j] == max1) count++;
    }
  }
  cout << count << endl;
}
