#include <bits/stdc++.h>
using namespace std;
vector<int> v, f;
string s;
int main() {
  int n, m, i, x, j;
  map<string, int> mp;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  for (i = 1; i <= m; i++) {
    cin >> s;
    mp[s]++;
  }
  map<string, int>::iterator it;
  int min = 0, max = 0;
  i = 0;
  j = n - 1;
  int cnt = 0;
  for (it = mp.begin(); it != mp.end(); it++) {
    f.push_back(it->second);
    cnt++;
  }
  sort(f.begin(), f.end());
  for (int k = cnt - 1; k >= 0; k--) {
    min += v[i] * f[k];
    max += v[j] * f[k];
    i++;
    j--;
  }
  printf("%d %d\n", min, max);
  return 0;
}
