#include <bits/stdc++.h>
using namespace std;
int main() {
  int T[100], n, m, d, T1[100];
  map<string, int> l;
  string a;
  cin >> n >> m;
  for (int j = 0; j < n; j++) {
    cin >> T1[j];
  }
  for (int i = 0; i < m; i++) {
    cin >> a;
    l[a]++;
  }
  int i = 0;
  for (map<string, int>::iterator it = l.begin(); it != l.end(); it++) {
    T[i] = (*it).second;
    i++;
  }
  int s = i;
  sort(T, T + s);
  sort(T1, T1 + n);
  int min = 0, max = 0;
  for (int i = 0; i < s; i++) {
    min += T[s - 1 - i] * T1[i];
    max += T[s - 1 - i] * T1[n - 1 - i];
  }
  cout << min << " " << max << endl;
  return 0;
}
