#include <bits/stdc++.h>
using namespace std;
bool check(char S[], long l) {
  for (long i = 0; i < l; i++)
    if (S[i] != '0') return 0;
  return 1;
}
int main() {
  long N, K, A[109];
  cin >> N >> K;
  for (long i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  map<string, long> M;
  string S;
  for (long i = 0; i < K; i++) {
    cin >> S;
    M[S] += 1;
  }
  vector<long> V;
  for (map<string, long>::iterator it = M.begin(); it != M.end(); it++)
    V.push_back(it->second);
  sort(V.rbegin(), V.rend());
  long L = V.size();
  long P = 0, Q = 0;
  for (long i = 0; i < L; i++) {
    P += (V[i] * A[i]);
    Q += (V[i] * A[N - i - 1]);
  }
  cout << P << " " << Q;
}
