#include <bits/stdc++.h>
using namespace std;
const int N = 101, M = 101;
int a[N];
string s[M];
int n, m;
const int L = 101;
int c[L];
int main() {
  string ss;
  int i, j = 0, k = 1, curr;
  int res1 = 0, res2 = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < m; i++) cin >> s[i];
  sort(a, a + n);
  sort(s, s + m);
  while (1) {
    for (i = j; i + 1 < m && s[i] == s[i + 1]; i++) s[i] = to_string(k);
    s[i] = to_string(k);
    k++;
    j = i + 1;
    if (i == m - 1) break;
  }
  k--;
  j = 0;
  while (k > 0) {
    curr = 0;
    ss = to_string(k);
    for (i = 0; i < m; i++)
      if (s[i] == ss) curr++;
    c[j] = curr;
    j++;
    k--;
  }
  sort(c, c + j);
  for (i = 0; i < j; i++) {
    res1 += c[j - i - 1] * a[i];
    res2 += c[j - i - 1] * a[n - i - 1];
  }
  cout << res1 << ' ' << res2 << endl;
  return 0;
}
