#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, k;
  long long int sump = 0;
  long long int sumv = 0;
  cin >> n;
  int arr[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr[a] = i;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> b;
    sump = sump + arr[b] + 1;
    sumv = sumv + n - arr[b];
  }
  cout << sump << " " << sumv;
}
