#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  double a;
  int ans = 0;
  vector<int> v;
  int n, m;
  cin >> n;
  int ara1[n];
  for (int i = 0; i < n; i++) cin >> ara1[i];
  cin >> m;
  int ara2[m];
  for (int i = 0; i < m; i++) cin >> ara2[i];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      a = (double)ara2[i] / ara1[j];
      if (a == (int)a) {
        int b = a;
        v.push_back(b);
      }
    }
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      a = (double)ara2[i] / ara1[j];
      if (a == v[0]) ans++;
    }
  }
  cout << ans;
  return 0;
}
