#include <bits/stdc++.h>
using namespace std;
map<string, int> Map;
int price[1000];
int main() {
  int i, n, m;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; ++i) {
    scanf("%d", &price[i]);
  }
  sort(price, price + n);
  string in;
  for (i = 0; i < m; ++i) {
    cin >> in;
    ++Map[in];
  }
  int Max = 0, Min = 0, pos;
  map<string, int>::iterator it = Map.begin();
  vector<int> vec;
  for (; it != Map.end(); ++it) {
    vec.push_back(it->second);
  }
  sort(vec.begin(), vec.end());
  for (pos = 0, i = 0; i < vec.size(); ++i, ++pos) {
    Max += price[n - pos - 1] * vec[vec.size() - 1 - i];
    Min += price[pos] * vec[vec.size() - 1 - i];
  }
  printf("%d %d\n", Min, Max);
  return 0;
}
