#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int p2;
  int m;
  scanf("%d%d", &n, &m);
  int a[200];
  char s[200][200];
  int count[200];
  int i;
  for (i = 0; i < 110; i++) {
    count[i] = 1;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  int no = 0;
  int j;
  int flag;
  for (i = 0; i < m; i++) {
    scanf("%s", s[no]);
    flag = 0;
    for (j = 0; j < no; j++) {
      if (strcmp(s[j], s[no]) == 0) {
        count[j]++;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      no++;
    }
  }
  sort(count, count + no);
  int min = 0;
  int max = 0;
  i = no - 1;
  j = 0;
  while (1) {
    if (i == -1) {
      break;
    }
    min = min + count[i] * a[j];
    i--;
    j++;
  }
  i = no - 1;
  j = n - 1;
  while (1) {
    max = max + count[i] * a[j];
    i--;
    j--;
    if (i == -1) {
      break;
    }
  }
  printf("%d %d\n", min, max);
  return 0;
}
