#include <bits/stdc++.h>
using namespace std;
int str[200];
int main() {
  int n, m, p[110], mi = 0, ma = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> p[i];
  string fru[110];
  bool dcd;
  for (int i = 0; i < m; i++) {
    cin >> fru[i];
    dcd = false;
    for (int j = 0; j < i && !dcd; j++) {
      if (fru[i] == fru[j]) {
        str[j]++;
        dcd = true;
      }
    }
    if (!dcd) str[i]++;
  }
  sort(str, str + m);
  sort(p, p + n);
  int amo[110], cnt = 0;
  for (int i = 0; i < m; i++) {
    if (str[i] > 0) amo[cnt++] = str[i];
  }
  for (int i = cnt - 1, j = 0, k = n - 1; i >= 0 && j < n && k >= 0;
       i--, j++, k--) {
    mi += amo[i] * p[j];
    ma += amo[i] * p[k];
  }
  cout << mi << " " << ma << endl;
}
