#include <bits/stdc++.h>
using namespace std;
int price[100];
map<string, int> M;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = (0); i < (n); ++i) cin >> price[i];
  string s;
  for (int i = (0); i < (m); ++i) {
    cin >> s;
    ++M[s];
  }
  vector<int> v;
  for (map<string, int>::iterator i = M.begin(); i != M.end(); ++i)
    v.push_back(i->second);
  sort((v).begin(), (v).end());
  sort(price, price + n);
  int best = 0, worst = 0;
  for (int i = 0; i < v.size(); ++i) {
    best += v[i] * price[v.size() - i - 1];
    worst += v[v.size() - i - 1] * price[n - i - 1];
  }
  cout << best << " " << worst << endl;
  return 0;
}
