#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T> read_vec(size_t n) {
  vector<T> r;
  for (size_t i = 0; i < n; ++i) {
    T t;
    cin >> t;
    r.push_back(t);
  }
  return r;
}
vector<string> read_vec_str(size_t n) {
  vector<string> r;
  for (size_t i = 0; i < n; ++i) {
    string s;
    getline(cin, s);
    if (s.empty()) {
      --i;
      continue;
    }
    r.push_back(s);
  }
  return r;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p = read_vec<int>(n);
  auto f = read_vec_str(m);
  map<string, int> mcnt;
  for (int i = 0; i < f.size(); ++i) ++mcnt[f[i]];
  vector<int> cnt;
  for (auto it = mcnt.begin(); it != mcnt.end(); ++it)
    cnt.push_back(it->second);
  sort(cnt.begin(), cnt.end(), greater<int>());
  sort(p.begin(), p.end());
  int minp = 0;
  for (int i = 0; i < cnt.size(); ++i) minp += cnt[i] * p[i];
  sort(p.begin(), p.end(), greater<int>());
  int maxp = 0;
  for (int i = 0; i < cnt.size(); ++i) maxp += cnt[i] * p[i];
  cout << minp << " " << maxp << endl;
  return 0;
}
