#include <bits/stdc++.h>
int main() {
  int n, m, cat[100] = {0}, i, count = 0, j, min = 0, max = 0, t, k, osho = 0;
  char s[100], name[100][100], c;
  scanf("%d %d", &n, &m);
  int price[100];
  for (i = 0; i < n; i++) {
    scanf("%d", &price[i]);
  }
  c = getchar();
  gets(name[0]);
  cat[0] = 1;
  count = 1;
  for (i = 1; i < m; i++) {
    gets(s);
    for (j = 0; j < count; j++) {
      if (strcmp(s, name[j]) == 0) {
        cat[j]++;
        goto proceed;
      }
    }
    cat[count] = 1;
    for (k = 0; s[k] != '\0'; k++) {
      name[count][k] = s[k];
    }
    name[count][k] = '\0';
    count++;
  proceed:
    osho++;
  }
  for (i = 0; i < count - 1; i++) {
    for (j = i + 1; j < count; j++) {
      if (cat[i] < cat[j]) {
        t = cat[i];
        cat[i] = cat[j];
        cat[j] = t;
      }
    }
  }
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (price[i] > price[j]) {
        t = price[i];
        price[i] = price[j];
        price[j] = t;
      }
    }
  }
  for (i = 0; i < count; i++) {
    min = min + (cat[i] * price[i]);
  }
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (price[i] < price[j]) {
        t = price[i];
        price[i] = price[j];
        price[j] = t;
      }
    }
  }
  for (i = 0; i < count; i++) {
    max = max + (cat[i] * price[i]);
  }
  printf("%d %d", min, max);
  return (0);
}
