#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  while (cin >> n >> m) {
    vector<int> a(n), c;
    map<string, int> b;
    for (int i = (0); i < ((n)); ++i) cin >> a[i];
    for (int j = (0); j < ((m)); ++j) {
      string t;
      cin >> t;
      b[t]++;
    }
    for (typeof((b).begin()) i = (b).begin(); i != (b).end(); ++i)
      c.push_back(i->second);
    sort((a).begin(), (a).end());
    sort((c).rbegin(), (c).rend());
    int mini = 0, maxi = 0;
    for (int i = (0); i < ((c.size())); ++i) {
      mini += a[i] * c[i];
      maxi += a[n - 1 - i] * c[i];
    }
    cout << mini << " " << maxi << endl;
  }
  return 0;
}
