#include <bits/stdc++.h>
using namespace std;
int n, m;
int price[101], fruit[101];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> price[i];
  map<string, int> fruits;
  for (int i = 0; i < m; i++) {
    char x[101];
    cin >> x;
    if (fruits.find(x) != fruits.end())
      fruits.find(x)->second++;
    else
      fruits.insert(make_pair(x, 1));
  }
  m = 0;
  for (auto i = fruits.begin(); i != fruits.end(); i++) fruit[m++] = i->second;
  sort(price, price + n);
  sort(fruit, fruit + m);
  int s = 0;
  for (int i = 0; i < m; i++) s += (price[i] * fruit[m - i - 1]);
  cout << s << " ";
  s = 0;
  for (int i = 0; i < m; i++) s += (price[n - i - 1] * fruit[m - i - 1]);
  cout << s;
  return 0;
}
