#include <bits/stdc++.h>
using namespace std;
int a[110], b[110];
map<string, int> mp;
int c[110];
char s[1111];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(c, 0, sizeof(c));
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  int id = 0;
  for (int i = 0; i < m; i++) {
    scanf("%s", s);
    if (mp.count(s) == 0) {
      mp[s] = id;
      c[id++] = 1;
    } else {
      c[mp[s]]++;
    }
  }
  sort(c, c + id);
  int MIN = 0, MAX = 0;
  int j = id - 1;
  for (int i = 0; i < n && j >= 0; i++, j--) {
    MIN += c[j] * a[i];
  }
  j = id - 1;
  for (int i = n - 1; i >= 0 && j >= 0; i--, j--) {
    MAX += c[j] * a[i];
  }
  printf("%d %d\n", MIN, MAX);
  return 0;
}
