#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, _min = 0, _max = 0;
  cin >> n >> m;
  vector<int> price(n);
  for (int i = 0; i < n; ++i) cin >> price[i];
  sort(price.begin(), price.end());
  map<string, int> M;
  string fruit;
  for (int i = 0; i < m; ++i) {
    cin >> fruit;
    M[fruit] += 1;
  }
  vector<int> count;
  for (auto iter : M) count.push_back(iter.second);
  sort(count.rbegin(), count.rend());
  for (int i = 0; i < count.size(); ++i) {
    _min += count[i] * price[i];
    _max += count[i] * price[n - i - 1];
  }
  cout << _min << " " << _max << endl;
  return 0;
}
