#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-5;
int main(void) {
  int N, M;
  int n, m;
  int i;
  cin >> N;
  cin >> M;
  vector<int> price(N);
  vector<string> list(0);
  vector<int> list_num(0);
  for (n = 0; n < N; n++) {
    cin >> price[n];
  }
  sort(price.begin(), price.end());
  for (m = 0; m < M; m++) {
    string s;
    cin >> s;
    int flag = 0;
    for (i = 0; i < list.size(); i++) {
      if (s == list[i]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      list.push_back(s);
      list_num.push_back(1);
    } else {
      list_num[i]++;
    }
  }
  sort(list_num.begin(), list_num.end());
  int min_price = 0;
  int max_price = 0;
  int l_num = list_num.size();
  int p_num = price.size();
  for (i = 0; i <= l_num - 1; i++) {
    min_price += list_num[i] * price[l_num - 1 - i];
    max_price += list_num[i] * price[p_num - (l_num - i)];
  }
  cout << min_price << " " << max_price;
  return 0;
}
