#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1;
  int Min = 0, Max = 0, i, j, n, m, count = 1;
  vector<string> v;
  vector<int> c;
  int a[110];
  scanf("%d %d ", &n, &m);
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = 1; i <= m; i++) {
    cin >> s1;
    v.push_back(s1);
  }
  sort(v.begin(), v.end());
  for (auto it = v.begin(); it != v.end(); it++) {
    if (*it == *(it + 1))
      count++;
    else {
      c.push_back(count);
      count = 1;
    }
  }
  sort(c.begin(), c.end());
  i = 0, j = n - 1;
  for (auto it = c.end() - 1; it >= c.begin(); it--) {
    Min += (*it) * a[i];
    Max += (*it) * a[j];
    i++, j--;
  }
  cout << Min << " " << Max << endl;
  return 0;
}
