#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  int m = 0;
  cin >> n >> m;
  vector<int> cost(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> cost[i];
  }
  map<string, int> want;
  for (int i = 0; i < m; ++i) {
    string t;
    cin >> t;
    want[t]++;
  }
  vector<int> b;
  for (map<string, int>::iterator it = want.begin(); it != want.end(); ++it) {
    b.push_back(it->second);
  }
  sort(cost.begin(), cost.end());
  sort(b.begin(), b.end());
  int min_c = 0;
  int max_c = 0;
  for (size_t i = 0; i < b.size(); ++i) {
    min_c += cost[i] * b[b.size() - 1 - i];
    max_c += cost[cost.size() - 1 - i] * b[b.size() - 1 - i];
  }
  cout << min_c << " " << max_c;
  return 0;
}
