#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, i, c = 1, d = 0, mi = 0, ma = 0;
  cin >> n >> m;
  int a[n];
  vector<string> s;
  vector<int> arr;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (i = 0; i < m; i++) {
    string str;
    cin >> str;
    s.push_back(str);
  }
  sort(s.begin(), s.end());
  i = 1;
  while (i < s.size()) {
    if (s[i - 1] == s[i]) {
      c = count(s.begin(), s.end(), s[i - 1]);
      arr.push_back(c);
      i = i + c;
      d++;
    } else {
      arr.push_back(1);
      i++;
      d++;
    }
  }
  if (s[m - 1] != s[m - 2]) {
    arr.push_back(1);
    d++;
  }
  sort(arr.begin(), arr.end(), greater<int>());
  for (i = 0; i < d; i++) {
    mi = mi + a[i] * arr[i];
  }
  for (i = 0; i < d; i++) {
    ma = ma + a[n - 1 - i] * arr[i];
  }
  cout << mi << " " << ma;
}
