#include <bits/stdc++.h>
using namespace std;
const int N = 702, M = 4900005;
int main() {
  int n, m, a[55], b, i, j, ans, cnt;
  while (scanf("%d", &n) == 1) {
    for (i = 1; i <= n; i++) scanf("%d", a + i);
    scanf("%d", &m);
    for (i = 1, ans = 0; i <= m; i++) {
      scanf("%d", &b);
      for (j = 1; j <= n; j++)
        if (b % a[j] == 0) {
          if (b / a[j] > ans) {
            ans = b / a[j];
            cnt = 1;
          } else if (b / a[j] == ans)
            cnt++;
        }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
