#include <bits/stdc++.h>
using namespace std;
int n, m, t[105], f[105], res;
string s;
map<string, int> fr;
int main() {
  cin >> n >> m;
  for (int(i) = 0; (i) < (n); ++(i)) scanf("%d", t + i);
  for (int(i) = 0; (i) < (m); ++(i)) {
    cin >> s;
    fr[s]++;
  }
  sort(t, t + n);
  m = fr.size();
  int i = 0;
  for (map<string, int>::const_iterator it = fr.begin(); it != fr.end(); ++it)
    f[i++] = it->second;
  sort(f, f + m);
  reverse(f, f + m);
  for (int(i) = 0; (i) < (m); ++(i)) res += f[i] * t[i];
  cout << res << ' ';
  res = 0;
  reverse(t, t + n);
  for (int(i) = 0; (i) < (m); ++(i)) res += f[i] * t[i];
  cout << res << endl;
  return 0;
}
