#include <bits/stdc++.h>
using namespace std;
int n, m, a[101], top, mina, maxa;
string s[101];
map<string, int> mp;
struct node {
  string ss;
  int num;
} t[101];
bool cmp(node aa, node bb) { return aa.num > bb.num; }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) cin >> s[i];
  sort(s + 1, s + m + 1);
  for (int i = 1; i <= m; i++) {
    mp[s[i]]++;
  }
  for (int i = 1; i <= m; i++) {
    if (s[i] == s[i - 1]) continue;
    t[++top].ss = s[i];
    t[top].num = mp[s[i]];
  }
  sort(t + 1, t + 1 + top, cmp);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= top; i++) {
    mina += t[i].num * a[i];
  }
  sort(a + 1, a + n + 1, greater<int>());
  for (int i = 1; i <= top; i++) {
    maxa += t[i].num * a[i];
  }
  cout << mina << ' ' << maxa << endl;
  return 0;
}
