#include <bits/stdc++.h>
using namespace std;
const int Size = int(1e5 + 7);
int n, m, arr[Size];
int main() {
  int i, j;
  long long a = 0, b = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j;
    arr[j] = i;
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> j;
    a += arr[j] + 1;
    b += n - arr[j];
  }
  cout << a << " " << b << endl;
  return 0;
}
