#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[55], b[55], n, m, i, j, mx, cnt, x, y;
  while (scanf("%d", &n) == 1) {
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    scanf("%d", &m);
    for (i = 0; i < m; i++) scanf("%d", &b[i]);
    mx = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        x = a[i];
        y = b[j];
        if (y % x == 0) {
          if (y / x > mx) {
            cnt = 1;
            mx = y / x;
          } else if (y / x == mx) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
