#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int n, m;
int a[110], b[110];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    mp.clear();
    for (int i = 0; i < (n); ++i) scanf("%d", a + i);
    for (int i = 0; i < (m); ++i) {
      string s;
      cin >> s;
      mp[s]++;
    }
    int tot = 0;
    for (map<string, int>::iterator it = mp.begin(); it != mp.end(); ++it)
      b[tot++] = it->second;
    sort(a, a + n);
    sort(b, b + tot);
    int mint = 0, maxt = 0;
    for (int i = 0; i < (tot); ++i)
      mint += a[i] * b[tot - 1 - i], maxt += a[n - tot + i] * b[i];
    printf("%d %d\n", mint, maxt);
  }
  return 0;
}
