#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, long long> mp;
  string s;
  map<string, long long>::iterator it;
  long long x, y, a = 0, b = 0, c = 0, d = 0, z = 0;
  vector<long long> vec;
  vector<long long> tec;
  cin >> x >> y;
  for (int i = 0; i < x; i++) {
    cin >> d;
    vec.push_back(d);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < y; i++) {
    cin >> s;
    mp[s]++;
  }
  for (it = mp.begin(); it != mp.end(); it++) {
    tec.push_back(it->second);
  }
  sort(tec.begin(), tec.end());
  a = 0;
  for (int i = tec.size() - 1; i >= 0; i--) {
    b += (vec[a] * tec[i]);
    a++;
  }
  c = x - 1;
  for (int i = tec.size() - 1; i >= 0; i--) {
    z += (vec[c] * tec[i]);
    c--;
  }
  cout << b << " " << z << endl;
  return 0;
}
