#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const long long LMXN = 1e14;
const int MOD = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (n); i++) cin >> a[i];
  int m;
  cin >> m;
  int b[m];
  for (int i = 0; i < (m); i++) cin >> b[i];
  int mx = 0, mn = 0;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (m); j++) {
      if (b[j] % a[i] == 0) {
        if (b[j] / a[i] > mx)
          mx = b[j] / a[i], mn = 1;
        else if (b[j] / a[i] == mx)
          mn++;
      }
    }
  }
  cout << mn << "\n";
}
int main() {
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
