#include <bits/stdc++.h>
using namespace std;
int main() {
  unordered_map<string, int> mymap;
  unordered_map<string, int>::iterator it;
  string str;
  int n, m;
  cin >> n >> m;
  int prices[n], items[m], j = 0;
  for (int i = 0; i < n; i++) cin >> prices[i];
  for (int i = 0; i < m; i++) {
    cin >> str;
    it = mymap.find(str);
    if (it == mymap.end()) {
      mymap.insert(make_pair(str, j));
      items[j] = 1;
      j += 1;
    } else {
      items[it->second] += 1;
    }
  }
  sort(prices, prices + n);
  sort(items, items + j);
  reverse(items, items + j);
  int max = 0, min = 0;
  int count = 0;
  for (int i = 0; i < j; i++) {
    min += items[i] * prices[i];
  }
  for (int i = 0; i < j; i++) {
    max += items[i] * prices[n - 1 - i];
  }
  cout << min << " " << max << endl;
}
