#include <bits/stdc++.h>
using namespace std;
bool bysec(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.second < b.second);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, x;
  cin >> n;
  int arr[1000005];
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    arr[x] = i;
  }
  long long q, cntx = 0, cnty = 0;
  cin >> q;
  while (q--) {
    cin >> x;
    cntx += arr[x];
    cnty += n - arr[x] + 1;
  }
  cout << cntx << " " << cnty << "\n";
  return 0;
}
