#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 1e3 + 10;
int main() {
  map<string, int> ms;
  int n, m;
  cin >> n >> m;
  vector<int> price(n);
  for (auto &x : price) cin >> x;
  while (m--) {
    string str;
    cin >> str;
    ms[str]++;
  }
  vector<int> v;
  for (auto &p : ms) {
    v.push_back(p.second);
  }
  sort(price.begin(), price.end());
  sort(v.rbegin(), v.rend());
  int ans1 = 0;
  for (int i = 0; i < v.size(); i++) ans1 += v[i] * price[i];
  int ans2 = 0;
  reverse(price.begin(), price.end());
  for (int i = 0; i < v.size(); i++) ans2 += v[i] * price[i];
  cout << ans1 << ' ' << ans2 << endl;
  return 0;
}
