#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1], i = 1, j, m;
  long long p = 0, q = 0;
  a[0] = 0;
  while (i <= n) {
    cin >> j;
    a[j] = i;
    i++;
  }
  i = 1;
  cin >> m;
  while (i <= m) {
    cin >> j;
    p += a[j];
    q += (n + 1 - a[j]);
    i++;
  }
  cout << p << " " << q;
  return 0;
}
