#include <bits/stdc++.h>
using namespace std;
char buf[32];
int Solution() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> mas(n);
  for (int i = 0; i < n; ++i) scanf("%d", &mas[i]);
  sort(mas.begin(), mas.end());
  map<string, int> fr;
  gets(buf);
  for (int i = 0; i < m; ++i) {
    gets(buf);
    string f = buf;
    if (fr.find(f) == fr.end())
      fr.insert(make_pair(f, 1));
    else
      fr[f]++;
  }
  map<string, int>::iterator it = fr.begin();
  vector<int> z;
  while (it != fr.end()) {
    z.push_back(it->second);
    ++it;
  }
  sort(z.rbegin(), z.rend());
  int res = 0;
  for (int i = 0; i < z.size(); ++i) res += z[i] * mas[i];
  printf("%d ", res);
  res = 0;
  for (int i = 0; i < z.size(); ++i) res += z[i] * mas[mas.size() - i - 1];
  printf("%d\n", res);
  return 0;
}
int main() {
  Solution();
  return 0;
}
