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