#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  string s;
  vector<pair<int, string> > mp;
  scanf("%d%d", &n, &m);
  int cost[n];
  int i, j;
  for (i = 0; i < n; i++) {
    scanf("%d", &cost[i]);
  }
  bool found = false;
  for (j = 0; j < m; j++) {
    cin >> s;
    found = false;
    for (i = 0; i < (int)(mp).size(); i++) {
      if (mp[i].second == s) {
        mp[i].first++;
        found = true;
      }
    }
    if (!found) mp.push_back(make_pair(1, s));
  }
  sort(cost, cost + n);
  sort(mp.begin(), mp.end());
  int mi = 0, mx = 0;
  j = (int)(mp).size() - 1;
  for (i = 0; i < (int)(mp).size(); i++) {
    mi += cost[i] * mp[j].first;
    j--;
  }
  j = n - 1;
  for (i = (int)(mp).size() - 1; i >= 0; i--) {
    mx += cost[j--] * mp[i].first;
  }
  printf("%d %d\n", mi, mx);
  return 0;
}
