#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
map<string, int>::iterator p;
string ss;
int pr[10000];
int cou[10000];
int cmp(int a, int b) { return a > b; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", pr + i);
  sort(pr + 1, pr + 1 + n);
  for (int i = 1; i <= m; i++) {
    cin >> ss;
    mp[ss]++;
  }
  int top = 0;
  for (p = mp.begin(); p != mp.end(); p++) cou[top++] = p->second;
  sort(cou, cou + top, cmp);
  int ans = 0;
  for (int i = 0; i < top; i++) ans += cou[i] * pr[i + 1];
  printf("%d", ans);
  ans = 0;
  sort(pr + 1, pr + 1 + n, cmp);
  for (int i = 0; i < top; i++) ans += cou[i] * pr[i + 1];
  printf(" %d\n", ans);
  return 0;
}
