#include <bits/stdc++.h>
using namespace std;
int cost[111], cnt[111];
string fruits[111];
int n, m, len, minans, maxans;
int main() {
  string str;
  bool fd;
  cin >> n >> m;
  for (register int i = 0; i < n; i++) cin >> cost[i];
  sort(cost, cost + n);
  for (register int i = 0; i < m; i++) {
    cin >> str;
    fd = false;
    for (register int j = 0; j < len; j++) {
      if (str == fruits[j]) {
        fd = true;
        cnt[j]++;
      }
    }
    if (!fd) {
      fruits[len] = str;
      cnt[len]++;
      len++;
    }
  }
  sort(cnt, cnt + len);
  for (register int j = 0, i = len - 1; i >= 0; i--, j++) {
    minans += cnt[i] * cost[j];
  }
  for (register int j = n - 1, i = len - 1; i >= 0; i--, j--) {
    maxans += cnt[i] * cost[j];
  }
  cout << minans << " " << maxans;
  return 0;
}
