#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)1e2;
int n, m;
vector<int> a, b;
void Assert(const int& value, const int& lowerBound, const int& upperBound) {
  assert(lowerBound <= value && value <= upperBound);
}
int main() {
  scanf("%d%d", &n, &m);
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  map<string, int> Map;
  string s;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    ++Map[s];
  }
  b.resize((int)Map.size());
  int sz = 0;
  for (map<string, int>::iterator it = Map.begin(); it != Map.end(); ++it) {
    b[sz++] = it->second;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(), greater<int>());
  int answer = 0;
  for (int i = 0; i < (int)b.size(); ++i) {
    answer += a[i] * b[i];
  }
  cout << answer << " ";
  answer = 0;
  sort(a.begin(), a.end(), greater<int>());
  sort(b.begin(), b.end(), greater<int>());
  for (int i = 0; i < (int)b.size(); ++i) {
    answer += a[i] * b[i];
  }
  cout << answer;
  return 0;
}
