#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int i, j, k;
  int price[105], namss[105];
  char nam[105][36];
  while (scanf("%d %d", &n, &m) != EOF) {
    memset(namss, 0, sizeof(namss));
    for (i = 1; i <= n; i++) scanf("%d", &price[i]);
    sort(price + 1, price + n + 1);
    for (i = 1; i <= m; i++) {
      k = 0;
      scanf("%s", &nam[i]);
      for (j = 1; j < i; j++) {
        if (strcmp(nam[i], nam[j]) == 0) {
          namss[j]++;
          k = 1;
          i--;
          m--;
          break;
        }
      }
      if (k == 0) {
        namss[i]++;
      }
    }
    sort(namss + 1, namss + m + 1);
    int ans1 = 0, ans2 = 0;
    for (i = m; i >= 1; i--) {
      ans1 = ans1 + namss[i] * price[m - i + 1];
      ans2 = ans2 + namss[i] * price[n - m + i];
    }
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}
