#include <bits/stdc++.h>
using namespace std;
int A[100010], X[100010], B[100010];
long long ans, ans1;
int main() {
  int n, i, m;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> A[i];
    X[A[i]] = i;
  }
  cin >> m;
  for (i = 1; i <= m; i++) {
    cin >> B[i];
    ans += X[B[i]];
  }
  for (i = 1; i <= n / 2; i++) swap(A[i], A[n - i + 1]);
  for (i = 1; i <= n; i++) X[A[i]] = i;
  for (i = 1; i <= m; i++) ans1 += X[B[i]];
  cout << ans << " " << ans1;
}
