#include <bits/stdc++.h>
using namespace std;
int i, n, maxx = -999999999, minn = 999999999;
bool isprime(int n) {
  if (n == 2) return 1;
  if (n < 2 || n % 2 == 0) return 0;
  for (int i = 3; i * i <= n; i += 2)
    if (n % i == 0) return 0;
  return 1;
}
int f[100009];
long long k1, k2;
int main() {
  int n, m, i, j;
  cin >> n;
  int a[n + 10];
  for (i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  int b[m + 10];
  for (i = 0; i < m; i++) {
    cin >> b[i];
    f[b[i]]++;
  }
  for (i = 0; i < n; i++)
    if (f[a[i]]) k1 += (i + 1) * f[a[i]];
  j = 0;
  for (i = n - 1; i >= 0; --i) {
    if (f[a[i]]) k2 += (j + 1) * f[a[i]];
    j++;
  }
  cout << k1 << " " << k2;
  return 0;
}
