#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> p(n), c;
  for (auto &e : (p)) {
    cin >> e;
  }
  map<string, int> cnt;
  for (int i = 0; i < int(m); i++) {
    string p;
    cin >> p;
    cnt[p]++;
  }
  for (auto e : (cnt)) {
    c.push_back(e.second);
  }
  sort((p).begin(), (p).end());
  sort((c).begin(), (c).end());
  int l = 0, r = 0;
  for (int i = 0; i < int(int((c).size())); i++) {
    r += c[int((c).size()) - i - 1] * p[int((p).size()) - 1 - i];
    l += c[int((c).size()) - i - 1] * p[i];
  }
  cout << l << " " << r;
  return 0;
}
