#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c = 1, i, j;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  int b[m];
  for (i = 0; i < m; i++) cin >> b[i];
  int gear = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      float p = (float)b[j] / a[i];
      if (p == floor(p)) {
        if (p == gear) {
          c++;
        }
        if (p > gear) {
          gear = p;
          c = 1;
        }
      }
    }
  }
  cout << c;
}
