#include <bits/stdc++.h>
using namespace std;
map<string, int> Q;
int pri[105];
int fru[105];
int cnt;
int main() {
  memset(pri, 0, sizeof(pri));
  memset(fru, 0, sizeof(fru));
  Q.clear();
  cnt = 1;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> pri[i];
  }
  string tmp;
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    if (Q[tmp] == 0) Q[tmp] = cnt++;
    fru[Q[tmp]]++;
  }
  int minans = 0, maxans = 0;
  sort(pri, pri + n);
  sort(fru, fru + cnt);
  for (int i = 1; i < cnt; i++) {
    minans += pri[i - 1] * fru[cnt - i];
  }
  for (int i = 1; i < cnt; i++) {
    maxans += pri[n - i] * fru[cnt - i];
  }
  cout << minans << " " << maxans << endl;
  return 0;
}
