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