#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a;
  int n, m, t;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> t;
    a.push_back(t);
  }
  string s;
  map<string, int> mp;
  for (int i = 0; i < m; i++) {
    cin >> s;
    mp[s]++;
  }
  vector<int> num;
  map<string, int>::iterator it;
  for (it = mp.begin(); it != mp.end(); it++) num.push_back(it->second);
  sort(num.begin(), num.end());
  sort(a.begin(), a.end());
  int mi, ma;
  mi = ma = 0;
  int k = num.size();
  for (int i = 0; i < k; i++) {
    mi += num[k - 1 - i] * a[i];
    ma += num[k - 1 - i] * a[a.size() - 1 - i];
  }
  cout << mi << " " << ma << endl;
  return 0;
}
