#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  map<string, int> o;
  vector<pair<int, string> > q;
  for (int i = 0; i < n; i++) cin >> a[i];
  while (m--) {
    string s;
    cin >> s;
    o[s]++;
  }
  for (map<string, int>::iterator it = o.begin(); it != o.end(); it++)
    q.push_back({it->second, it->first});
  sort(q.begin(), q.end());
  sort(a.begin(), a.end());
  int mini = 0, maxi = 0, l = 0;
  for (int i = q.size() - 1; i >= 0; i--) {
    mini += q[i].first * a[l];
    l++;
  }
  l = a.size() - 1;
  for (int i = q.size() - 1; i >= 0; i--) {
    maxi += q[i].first * a[l];
    l--;
  }
  cout << mini << " " << maxi;
  return 0;
}
