#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  string s;
  vector<string> v;
  map<string, long long int> check;
  long long int ara[n];
  for (long long int i = 0; i < n; i++) cin >> ara[i];
  for (long long int i = 0; i < m; i++) {
    cin >> s;
    v.push_back(s);
    check[s]++;
  }
  vector<pair<long long int, string> > vp;
  for (long long int i = 0; i < m; i++) {
    if (check[v[i]]) {
      vp.push_back(make_pair(check[v[i]], v[i]));
      check[v[i]] = 0;
    }
  }
  sort(vp.begin(), vp.end());
  sort(ara, ara + n);
  long long int j = 0, mi = 0;
  for (long long int i = vp.size() - 1; i >= 0; i--) {
    mi += (vp[i].first * ara[j]);
    j++;
  }
  sort(ara, ara + n, greater<long long int>());
  j = 0;
  long long int mx = 0;
  for (long long int i = vp.size() - 1; i >= 0; i--) {
    mx += (vp[i].first * ara[j]);
    j++;
  }
  cout << mi << " " << mx << endl;
}
