#include <bits/stdc++.h>
using namespace std;
map<string, int> found;
vector<pair<int, string> > all;
int main() {
  int N, M;
  cin >> N >> M;
  int P[110];
  string names[110];
  found.clear();
  for (int i = 0; i < N; i++) cin >> P[i];
  sort(P, P + N);
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    string t;
    cin >> t;
    if (found[t] > 0)
      found[t]++;
    else
      names[cnt++] = t, found[t] = 1;
  }
  all.clear();
  for (int i = 0; i < cnt; i++)
    all.push_back(make_pair(found[names[i]], names[i]));
  sort(all.begin(), all.end());
  int mini = 0, maxi = 0;
  for (int i = 0, j = cnt - 1; j >= 0; i++, j--) mini += (P[i] * all[j].first);
  for (int i = N - 1, j = cnt - 1; j >= 0; i--, j--)
    maxi += (P[i] * all[j].first);
  cout << mini << " " << maxi << "\n";
  return 0;
}
