#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  map<int, int> uchs;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (uchs.find(x) != uchs.end()) {
      (uchs.at(x))++;
    } else
      uchs.insert(pair<int, int>(x, 1));
  }
  cin >> m;
  vector<int> films;
  films.reserve(m);
  int max = 0;
  for (int j = 0; j < m; j++) {
    int x;
    cin >> x;
    if (uchs.find(x) != uchs.end()) {
      if (uchs.at(x) > max) {
        films.clear();
        max = uchs.at(x);
        films.push_back(j);
      } else if (uchs.at(x) == max) {
        films.push_back(j);
      }
    } else if (max == 0) {
      films.push_back(j);
    }
  }
  int kinco = films[0] + 1;
  int newmax = 0;
  int r = 0;
  for (int j = 0; j < m; j++) {
    int x;
    cin >> x;
    if (films[r] == j) {
      r++;
      if (uchs.find(x) != uchs.end()) {
        if (uchs.find(x)->second > newmax) {
          kinco = j + 1;
          newmax = uchs.find(x)->second;
        }
      }
      if (r == films.size()) break;
    }
  }
  cout << kinco;
  return 0;
}
