#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100], b[100];
int main() {
  int i, j, ans = -1, ans1 = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> m;
  for (j = 1; j <= m; j++) cin >> b[j];
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (b[j] % a[i] == 0) {
        if (b[j] / a[i] == ans)
          ans1++;
        else if (b[j] / a[i] > ans) {
          ans = b[j] / a[i];
          ans1 = 1;
        }
      }
    }
  cout << ans1 << endl;
  return 0;
}
