#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> m;
  int b[m];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  multiset<int> ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[j] / a[i] == (float)b[j] / a[i]) {
        ans.insert(b[j] / a[i]);
      }
    }
  }
  cout << ans.count(*(ans.rbegin()));
  return 0;
}
