#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a, b;
  vector<long long> price;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a;
    price.push_back(a);
  }
  map<string, long long> mp;
  vector<string> s1;
  vector<long long> p1;
  for (int i = 0; i < m; i++) {
    string str;
    cin >> str;
    if (mp[str] == 0) {
      s1.push_back(str);
      mp[str] = 1;
    } else {
      mp[str]++;
    }
  }
  for (int i = 0; i < s1.size(); i++) {
    p1.push_back(mp[s1[i]]);
  }
  sort(p1.begin(), p1.end());
  sort(price.begin(), price.end());
  long long mnp = 0;
  long long mxp = 0;
  long long c = 0;
  for (int i = p1.size() - 1; i >= 0; i--) {
    mnp += p1[i] * price[c];
    c++;
  }
  reverse(price.begin(), price.end());
  c = 0;
  for (int i = p1.size() - 1; i >= 0; i--) {
    mxp += p1[i] * price[c];
    c++;
  }
  cout << mnp << "  " << mxp << endl;
  return 0;
}
