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