#include <bits/stdc++.h>
using namespace std;
bool sortt(const pair<long long, string> &a, const pair<long long, string> &b) {
  return (a.first > b.first);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, mn = 0, mx = 0;
  cin >> n >> m;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long k = m;
  map<string, long long> meh;
  while (k--) {
    string s;
    cin >> s;
    if (meh.find(s) != meh.end())
      meh[s]++;
    else {
      meh[s] = 1;
    }
  }
  vector<pair<long long, string> > v;
  sort(arr, arr + n);
  auto it = meh.begin();
  for (it = meh.begin(); it != meh.end(); it++) {
    v.push_back({(*it).second, (*it).first});
  }
  sort(v.begin(), v.end(), sortt);
  for (long long i = 0; i < v.size(); i++) {
    mn += v[i].first * arr[i];
  }
  k = n - 1;
  for (long long i = 0; i < v.size(); i++) {
    mx += v[i].first * arr[k];
    k--;
  }
  cout << mn << " " << mx;
}
