#include <bits/stdc++.h>
using namespace std;
int a, b, cnt = 0;
int price_tag[200], kind[200], qnt[200];
map<string, int> name_to_id;
int main(int argc, char const *argv[]) {
  cin >> a >> b;
  for (long long i = 0; i < a; i++) {
    cin >> price_tag[i];
  }
  for (long long i = 0; i < b; i++) {
    string tmp;
    cin >> tmp;
    if (!name_to_id[tmp]) name_to_id[tmp] = cnt + 1;
    cnt++;
    qnt[name_to_id[tmp] - 1]++;
  }
  sort(qnt, qnt + cnt);
  sort(price_tag, price_tag + a);
  long long maxsum = 0, minsum = 0;
  for (long long i = 0; i < cnt; i++) {
    maxsum += (long long)qnt[i] * price_tag[a - cnt + i];
    minsum += (long long)qnt[i] * price_tag[cnt - 1 - i];
  }
  cout << minsum << " " << maxsum << endl;
}
