#include <bits/stdc++.h>
int strlen(char *str) {
  int i = 0;
  while (str[i]) {
    i++;
  }
  return i;
}
int cuvinteEgale(char *s1, char *s2) {
  if (strlen(s1) != strlen(s2)) {
    return 0;
  }
  for (int i = 0; i < strlen(s1); i++) {
    if (s1[i] != s2[i]) {
      return 0;
    }
  }
  return 1;
}
void bubbleSort(int n, int array[]) {
  int i, j;
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < n - i - 1; j++) {
      if (array[j] > array[j + 1]) {
        int temp = array[j];
        array[j] = array[j + 1];
        array[j + 1] = temp;
      }
    }
  }
}
int findFruit(char **foundFruits, int nrDifferentFruits, char *fruit) {
  for (int i = 0; i < nrDifferentFruits; i++) {
    if (cuvinteEgale(foundFruits[i], fruit)) {
      return i;
    }
  }
  return -1;
}
int main() {
  int nrPrices, nrFruits;
  int *prices;
  char **fruits;
  char **foundFruits;
  scanf("%d %d", &nrPrices, &nrFruits);
  prices = (int *)malloc(nrPrices * sizeof(int));
  fruits = (char **)malloc(nrFruits * sizeof(char *));
  foundFruits = (char **)malloc(nrFruits * sizeof(char *));
  for (int i = 0; i < nrPrices; i++) {
    scanf("%d", &prices[i]);
  }
  for (int i = 0; i < nrFruits; i++) {
    fruits[i] = (char *)malloc(33 * sizeof(char));
    scanf("%s", fruits[i]);
  }
  printf("\n");
  bubbleSort(nrPrices, prices);
  int *countTypeFruits;
  int nrDifferentFruits = 0;
  countTypeFruits = (int *)malloc(nrFruits * sizeof(int));
  for (int i = 0; i < nrFruits; i++) {
    int fruitId = findFruit(foundFruits, nrDifferentFruits, fruits[i]);
    if (fruitId != -1) {
      countTypeFruits[fruitId]++;
    } else {
      countTypeFruits[nrDifferentFruits] = 1;
      foundFruits[nrDifferentFruits] = fruits[i];
      nrDifferentFruits++;
    }
  }
  free(foundFruits);
  bubbleSort(nrDifferentFruits, countTypeFruits);
  int min = 0;
  int max = 0;
  for (int i = 0; i < nrDifferentFruits; i++) {
    min += countTypeFruits[nrDifferentFruits - i - 1] * prices[i];
  }
  for (int i = 0; i < nrDifferentFruits; i++) {
    max +=
        countTypeFruits[nrDifferentFruits - i - 1] * prices[nrPrices - i - 1];
  }
  printf("%d %d\n", min, max);
}
