#include <bits/stdc++.h>
using namespace std;
int n, m, a[101], MIN = 0, MAX = 0;
string name;
vector<pair<int, string> > q;
int str(pair<int, string> a, pair<int, string> b) {
  if (a.first > b.first) return 1;
  return 0;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> name;
    bool f = false;
    for (int j = 0; j < q.size(); j++)
      if (q[j].second == name) {
        q[j].first++;
        f = true;
        break;
      }
    if (!f) q.push_back(make_pair(1, name));
  }
  sort(q.begin(), q.end(), str);
  sort(a, a + n);
  for (int i = 0; i < q.size(); i++) MIN += q[i].first * a[i];
  for (int i = 0, j = n - 1; i < q.size(); i++, j--) MAX += q[i].first * a[j];
  cout << MIN << " " << MAX;
  return 0;
}
