#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int(i) = 0; (i) < (n); ++(i)) cin >> a[i];
  sort((a).begin(), (a).end());
  map<string, int> b;
  string s;
  for (int(j) = 0; (j) < (m); ++(j)) {
    cin >> s;
    b[s]++;
  }
  vector<int> c;
  for (__typeof((b).begin()) i = (b).begin(); i != (b).end(); ++i)
    c.push_back(i->second);
  sort((c).begin(), (c).end());
  reverse((c).begin(), (c).end());
  int Min = 0;
  for (int(i) = 0; (i) < (((int)(c).size())); ++(i)) Min += c[i] * a[i];
  reverse((a).begin(), (a).end());
  int Max = 0;
  for (int(i) = 0; (i) < (((int)(c).size())); ++(i)) Max += c[i] * a[i];
  cout << Min << " " << Max;
  return 0;
}
