#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<pair<int, string> > vc;
  map<string, int> mp;
  vector<int> p;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    p.push_back(x);
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < m; i++) {
    string x;
    cin >> x;
    mp[x]++;
  }
  for (auto it = mp.begin(); it != mp.end(); it++)
    vc.push_back({it->second, it->first});
  sort(vc.begin(), vc.end());
  long long mn = 0, mx = 0;
  int pt1 = 0, pt2 = n - 1;
  for (int i = vc.size() - 1; i >= 0; i--) {
    mn += vc[i].first * p[pt1];
    mx += vc[i].first * p[pt2];
    pt1++, pt2--;
  }
  cout << mn << " " << mx << endl;
  return 0;
}
