#include <bits/stdc++.h>
using namespace std;
map<string, int> P;
map<string, bool> L;
int A[101];
string S[101], R;
int f(int a, int b) {
  if (a != b) return a > b;
}
int main(int argc, char *argv[]) {
  int N, M, i, j, ans1 = 0, ans2 = 0, count = -1, ters;
  cin >> N >> M;
  ters = N;
  for (i = 0; i <= N - 1; i++) cin >> A[i];
  for (i = 1; i <= M; i++) {
    cin >> S[i];
    P[S[i]]++;
  }
  sort(A, A + N);
  for (i = 1; i <= M; i++) {
    int maxi = -1;
    bool f = false;
    for (j = 1; j <= M; j++)
      if (!L[S[j]]) {
        if (P[S[j]] > maxi) {
          maxi = P[S[j]];
          R = S[j];
        }
        f = true;
      }
    if (f) {
      count++;
      ters--;
      L[R] = true;
      ans1 += maxi * A[count];
      ans2 += maxi * A[ters];
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
