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