#include <bits/stdc++.h>
using namespace std;
map<string, int> M;
int main() {
  int n, m;
  scanf("%d %d\n", &n, &m);
  vector<int> vec;
  vector<int> nums;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    vec.push_back(x);
  }
  getchar();
  for (int i = 0; i < m; ++i) {
    char s[50];
    gets(s);
    if (M.find(string(s)) == M.end())
      M[string(s)] = 1;
    else
      M[string(s)]++;
  }
  for (map<string, int>::iterator it = M.begin(); it != M.end(); ++it) {
    nums.push_back(it->second);
  }
  sort(nums.begin(), nums.end());
  reverse(nums.begin(), nums.end());
  sort(vec.begin(), vec.end());
  int mini = 0;
  int maxi = 0;
  for (int i = 0; i < nums.size(); ++i) {
    mini += nums[i] * vec[i];
    maxi += nums[i] * vec[n - i - 1];
  }
  printf("%d %d\n", mini, maxi);
  return 0;
}
