#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int k = 1e5;
  int x[k];
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    x[a] = i + 1;
  }
  int m;
  cin >> m;
  long long s1 = 0, s2 = 0;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    s1 += x[a];
    s2 += n - x[a] + 1;
  }
  cout << s1 << " " << s2 << endl;
  return 0;
}
