#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
int main() {
  int i, j, m, n, ans1 = 0, ans2 = 0, l1, l2;
  scanf("%d", &n);
  scanf("%d", &m);
  vector<int> a, b;
  map<string, int> M;
  string s;
  for (int i = (int)0; i < (int)n; ++i) {
    scanf("%d", &j);
    a.push_back(j);
  }
  sort(a.begin(), a.end());
  for (int i = (int)0; i < (int)m; ++i) {
    cin >> s;
    if (M.find(s) != M.end()) {
      M[s]++;
    } else {
      M[s] = 1;
    }
  }
  for (typeof(M.begin()) it = M.begin(); it != M.end(); it++) {
    b.push_back(it->second);
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  l1 = int((a).size());
  l2 = int((b).size());
  for (int i = (int)0; i < (int)l2; ++i) {
    ans1 += b[i] * a[i];
    ans2 += b[i] * a[l1 - i - 1];
  }
  printf("%d ", ans1);
  printf("%d\n", ans2);
  return 0;
}
