#include <bits/stdc++.h>
using namespace std;
int p[100];
int q[100];
map<string, int> f;
int main(void) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    if (f.find(s) == f.end())
      f[s] = 1;
    else
      f[s]++;
  }
  int k = 0;
  for (auto &it : f) q[k++] = it.second;
  auto cmp = [](int a, int b) { return a > b; };
  sort(p, p + n);
  sort(q, q + k, cmp);
  int min = 0;
  for (int i = 0; i < k; i++) min += p[i] * q[i];
  sort(p, p + n, cmp);
  int max = 0;
  for (int i = 0; i < m; i++) max += p[i] * q[i];
  cout << min << " " << max << endl;
  return 0;
}
