#include <bits/stdc++.h>
using namespace std;
int n, m, price[100], mx, mn;
string x;
map<string, int> cnt_str;
set<string> my_list;
vector<int> yara;
void take_input() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> price[i];
  for (int i = 0; i < m; i++) {
    cin >> x;
    my_list.insert(x);
    cnt_str[x]++;
  }
}
void cnt_fruit() {
  set<string>::iterator it;
  for (it = my_list.begin(); it != my_list.end(); it++)
    yara.push_back(cnt_str[*it]);
}
void solve() {
  sort(price, price + n);
  sort(yara.begin(), yara.end());
  reverse(yara.begin(), yara.end());
  for (int i = 0; i < my_list.size(); i++) {
    mn += yara[i] * price[i];
  }
  reverse(price, price + n);
  for (int i = 0; i < my_list.size(); i++) {
    mx += yara[i] * price[i];
  }
}
void print() { cout << mn << " " << mx << endl; }
int main() {
  take_input();
  cnt_fruit();
  solve();
  print();
  return 0;
}
