#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, m, n, a, b, pri[110], flag[110];
  string str[110], str1;
  memset(flag, 0, sizeof(flag));
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &pri[i]);
  }
  cin >> str[0];
  flag[0] = 1;
  k = 1;
  for (i = 1; i < m; i++) {
    l = 0;
    cin >> str1;
    for (j = 0; j < k; j++) {
      if (str1 == str[j]) {
        l = 1;
        flag[j]++;
        break;
      }
    }
    if (l == 0) {
      str[k++] = str1;
      flag[k - 1] = 1;
    }
  }
  sort(flag, flag + k);
  sort(pri, pri + n);
  a = 0;
  b = 0;
  for (i = k - 1; i >= 0; i--) {
    a += (flag[i] * pri[k - 1 - i]);
  }
  n--;
  for (i = k - 1; i >= 0; i--) {
    b += (flag[i] * pri[n--]);
  }
  printf("%d %d\n", a, b);
  return 0;
}
