#include <bits/stdc++.h>
using namespace std;
long long cnt[10000];
int main() {
  long long n, m, k(0), c(1), mxsum(0), mnsum(0);
  cin >> n >> m;
  string *s = new string[m];
  long long *arr = new long long(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < m; i++) cin >> s[i];
  sort(arr, arr + n);
  sort(s, s + m);
  for (int i = 0; i < m; i++) {
    if (s[i] != s[i + 1])
      cnt[k] = c, c = 1, k++;
    else
      c++;
  }
  sort(cnt, cnt + k);
  for (int i = k - 1, j = 0; i >= 0; i--, j++) mnsum += (cnt[i] * arr[j]);
  for (int i = k - 1, j = n - 1; i >= 0; i--, j--) mxsum += (cnt[i] * arr[j]);
  cout << mnsum << " " << mxsum << endl;
  return 0;
}
