#include <bits/stdc++.h>
using namespace std;
vector<pair<string, long long> > v;
bool cmp(pair<string, long long>& p, pair<string, long long>& q) {
  return p.second > q.second;
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n];
  map<string, long long> mp;
  map<string, long long>::iterator it;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    string st;
    cin >> st;
    mp[st]++;
  }
  for (it = mp.begin(); it != mp.end(); it++) {
    v.push_back(*it);
  }
  sort(a, a + n);
  sort(v.begin(), v.end(), cmp);
  long long mn = 0, mx = 0;
  for (int i = 0, j = n - 1; i < v.size(); i++, j--) {
    mn += a[i] * v[i].second;
    mx += a[j] * v[i].second;
  }
  cout << mn << " " << mx << endl;
}
