#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int x;
  map<int, pair<int, int>> m;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (m.find(x) == m.end()) {
      m[x].first = i;
      m[x].second = i;
    } else {
      m[x].first = min(m[x].first, i);
      m[x].second = max(m[x].second, i);
    }
  }
  int q, b;
  cin >> q;
  ll vasya = 0, petya = 0;
  while (q--) {
    cin >> b;
    vasya += m[b].first + 1;
    petya += n - m[b].second;
  }
  cout << vasya << " " << petya;
  return 0;
}
