#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, tam, tam2, aux, con, P[100];
  string F[100];
  tam = 0;
  aux = 0;
  con = 0;
  tam2 = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> P[i];
    tam++;
  }
  for (i = 0; i < m; i++) {
    cin >> F[i];
    tam2++;
  }
  sort(P, P + tam);
  sort(F, F + tam2);
  int F2[tam2];
  for (i = 0; i < tam2; i++) F2[i] = 1;
  for (i = 1; i < m; i++) {
    if (F[i] == F[i - 1]) {
      F2[i] = F2[i - 1] + 1;
      F2[i - 1] = 0;
      con++;
    }
  }
  sort(F2, F2 + tam2);
  int smax = 0, smin = 0;
  for (i = 0; i < tam2; i++) smin = smin + F2[tam2 - i - 1] * P[i];
  for (i = 0; i < tam2; i++) smax = smax + F2[tam2 - i - 1] * P[tam - i - 1];
  cout << smin << " " << smax;
  return 0;
}
