#include <bits/stdc++.h>
long long INFF = 8000000000000000000LL;
using namespace std;
long stoi(string s) {
  long n = 0;
  for (int i = 0; i < s.size(); i++) n = n * 10 + s[i] - 48;
  return n;
}
string itos(long n) {
  string s = "";
  while (n) {
    s += char(n % 10 + 48);
    n = n / 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
long long res = 0, n, nn, m, mm, k = 0, mx = -(1 << 30), mn = (1 << 30), c = 0,
          cc = 0, ccc = 0;
long long ar[1 << 21] = {0};
long long ar1[1 << 21] = {0};
string s, ss, s1, s2;
int main() {
  string s;
  long long a;
  map<string, int> mp;
  vector<long long> v, vv;
  cin >> n >> m;
  for (long i = 0; i < n; i++) {
    cin >> a;
    vv.push_back(a);
  }
  sort(vv.begin(), vv.end());
  for (long i = 0; i < m; i++) {
    cin >> s;
    mp[s]++;
  }
  map<string, int>::iterator it;
  for (it = mp.begin(); it != mp.end(); it++) {
    v.push_back(it->second);
  }
  long long res = 0, res1 = 0;
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (long i = 0; i < ((int)(v.size())); i++) {
    res += v[i] * vv[i];
  }
  reverse(vv.begin(), vv.end());
  for (long i = 0; i < ((int)(v.size())); i++) {
    res1 += v[i] * vv[i];
  }
  cout << res << " " << res1 << endl;
  return 0;
}
