#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, startApp = 0, endApp = 0;
  cin >> n;
  int indexes[n + 1];
  int x;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    indexes[x] = i;
  }
  int qn;
  cin >> qn;
  while (qn--) {
    cin >> x;
    startApp += indexes[x];
    endApp += (n + 1 - indexes[x]);
  }
  cout << startApp << " " << endApp << endl;
  return 0;
}
