#include <bits/stdc++.h>
using namespace std;
int nextInt() {
  int ret = 0, sign = 1;
  char c = ' ';
  while (!isdigit(c = getchar())) {
    if (c == EOF) return -1;
    if (c == '-') sign = -1;
  }
  do {
    ret = ret * 10 + (c - '0');
  } while (isdigit(c = getchar()));
  return ret * sign;
}
void printlineInt(int num) {
  char str[101];
  if (num < 0)
    num = -num, putchar('-');
  else if (num == 0) {
    puts("0");
    return;
  }
  str[100] = '\0';
  int i = 99;
  for (; num; i--) {
    str[i] = num % 10 + '0';
    num /= 10;
  }
  puts(&str[i + 1]);
  return;
}
int N, M;
int tag[101];
int cnt[101];
int sz;
map<string, int> ntoi;
int main() {
  while (cin >> N >> M) {
    memset(cnt, 0, sizeof(cnt));
    ntoi.clear();
    sz = 0;
    for (int i = 0; i < (int)N; i++) {
      tag[i] = nextInt();
    }
    sort(tag, tag + N);
    for (int i = 0; i < (int)M; i++) {
      string s;
      cin >> s;
      if (ntoi.find(s) == ntoi.end()) {
        ntoi[s] = sz++;
      }
      cnt[ntoi[s]]++;
    }
    sort(cnt, cnt + M);
    int a = 0, m = 0;
    for (int i = M - 1, j = 0; i >= 0 && cnt[i]; i--, j++) {
      a += cnt[i] * tag[j];
    }
    for (int i = M - 1, j = N - 1; i >= 0 && cnt[i]; i--, j--) {
      m += cnt[i] * tag[j];
    }
    printf("%d %d\n", a, m);
  }
}
