#include <bits/stdc++.h>
using namespace std;
const int mxn = 2048;
int n, M;
map<string, int> m;
int a[128];
int cnt[128];
int main() {
  cin >> n >> M;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  string s;
  while (M--) {
    cin >> s;
    m[s]++;
  }
  int x = 0;
  for (map<string, int>::iterator i = m.begin(); i != m.end(); i++) {
    cnt[x++] = i->second;
  }
  int mi = 0;
  sort(cnt, cnt + x);
  for (int i = 0, k = x - 1; i < n && k >= 0; i++, k--) {
    mi += cnt[k] * a[i];
  }
  int mx = 0;
  for (int i = x - 1, k = n - 1; i >= 0 && k >= 0; i--, k--) {
    mx += cnt[i] * a[k];
  }
  printf("%d %d\n", mi, mx);
}
