#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[200];
  string b[200];
  set<string> s;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    s.insert(b[i]);
  }
  int sz = 0, p[200];
  for (set<string>::iterator it = s.begin(); it != s.end(); it++) {
    p[sz++] = count(b, b + m, *it);
  }
  sort(p, p + sz);
  sort(a, a + n);
  int r1 = 0, r2 = 0;
  for (int i = 0; i < sz; i++) {
    r1 += p[sz - i - 1] * a[i];
  }
  for (int i = sz - 1, j = n - 1; i >= 0; i--, j--) {
    r2 += a[j] * p[i];
  }
  cout << r1 << " " << r2 << endl;
  return 0;
}
