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