#include <bits/stdc++.h>
using namespace std;
void FastInputOutput() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  int n, temp;
  map<int, int> idx;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &temp);
    idx[temp] = i;
  }
  int q;
  long long l = 0, r = 0;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &temp);
    l += idx[temp], r += n - idx[temp] + 1;
  }
  printf("%lld %lld", l, r);
  return 0;
}
