#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[1005];
  for (int i = 0; i < n; ++i) cin >> a[i];
  map<string, int> fr;
  for (int i = 0; i < m; ++i) {
    string cs;
    cin >> cs;
    fr[cs]++;
  }
  vector<int> tt;
  for (map<string, int>::iterator it = fr.begin(); it != fr.end(); ++it)
    tt.push_back((*it).second);
  sort(a, a + n);
  sort(tt.begin(), tt.end());
  long long mxres = 0, mnres = 0;
  for (int i = 0; i < tt.size(); ++i) {
    mxres += tt[i] * a[n - tt.size() + i];
  }
  reverse(tt.begin(), tt.end());
  for (int i = 0; i < tt.size(); ++i) {
    mnres += tt[i] * a[i];
  }
  cout << mnres << " " << mxres;
  return 0;
}
