#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[105][40];
  int i, j, m, n, s, sum = 0, qum = 0;
  int b[105], c[260];
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(c, 0, sizeof(c));
    for (i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
    }
    sort(b + 1, b + n + 1);
    getchar();
    for (i = 1; i <= m; i++) {
      scanf("%s", a[i]);
      c[i] = 1;
    }
    for (i = 2; i <= m; i++) {
      for (j = 1; j < i; j++) {
        if (strcmp(a[i], a[j]) == 0) {
          c[i]++;
          c[j] = 0;
        }
      }
    }
    sort(c + 1, c + m + 1);
    for (i = 1, j = m; i <= n; i++, j--) {
      sum += b[i] * c[j];
      if (j == 0) break;
    }
    for (i = n, j = m; i >= 0; i--, j--) {
      qum += b[i] * c[j];
      if (j == 0) break;
    }
    printf("%d %d\n", sum, qum);
    sum = 0, qum = 0;
  }
  return 0;
}
