#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
int main(int argc, char **argv) {
  ifstream from;
  const int fin = 0;
  const int err = 0;
  const long long nmin = 1, nmax = 100;
  long long n, m, res, res0, res1, rt, i, j, k, ax;
  string s;
  if (fin) from.open("test.txt");
  if (fin)
    from >> n >> m;
  else
    cin >> n >> m;
  vector<long long> v(n), v0(n), v1(n), vm;
  map<string, long long> ms;
  for (i = 0; i < n; i++) {
    if (fin)
      from >> v[i];
    else
      cin >> v[i];
  }
  for (i = 0; i < m; i++) {
    if (fin)
      from >> s;
    else
      cin >> s;
    if (ms.end() == ms.find(s))
      ms[s] = 1;
    else
      ms[s]++;
  }
  k = ms.size();
  vm.resize(k);
  i = 0;
  for (map<string, long long>::const_iterator p = ms.begin(); p != ms.end();
       p++) {
    vm[i++] = p->second;
  }
  for (i = 0; i < k - 1; i++) {
    for (j = i + 1; j < k; j++) {
      if (vm[j] > vm[i]) {
        rt = vm[i];
        vm[i] = vm[j];
        vm[j] = rt;
      }
    }
  }
  v0 = v1 = v;
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (v0[j] < v0[i]) {
        rt = v0[i];
        v0[i] = v0[j];
        v0[j] = rt;
      }
      if (v1[j] > v1[i]) {
        rt = v1[i];
        v1[i] = v1[j];
        v1[j] = rt;
      }
    }
  }
  res0 = res1 = 0;
  for (i = 0; i < k; i++) {
    res0 += v0[i] * vm[i];
    res1 += v1[i] * vm[i];
  }
  cout << res0 << ' ' << res1 << endl;
  return 0;
}
