#include <bits/stdc++.h>
using namespace std;
int a[101], n, m, cnt[101];
string s[101], x[101];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> s[i];
  sort(a, a + n);
  sort(s, s + m);
  int mini = 0, maxi = 0, p = 0;
  for (int i = 0; i < m;) {
    x[p] = s[i];
    int j;
    for (j = i + 1; j < m && s[j] == s[i]; j++)
      ;
    cnt[p++] = j - i;
    i = j;
  }
  for (int i = 0; i < p; i++)
    for (int j = i + 1; j < p; j++)
      if (cnt[i] < cnt[j]) {
        swap(cnt[i], cnt[j]);
        swap(x[i], x[j]);
      }
  int ptr = 0;
  for (int i = 0; i < p; i++) mini += cnt[i] * a[ptr++];
  ptr = n - 1;
  for (int i = 0; i < p; i++) maxi += cnt[i] * a[ptr--];
  cout << mini << " " << maxi << endl;
}
