#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000000000ll;
const double pi = acos(-1.0);
int p[100];
int main() {
  map<string, int> f;
  memset(p, 200, sizeof(p));
  vector<int> v;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> p[i];
  string s;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    if (f.find(s) == f.end())
      f[s] = 1;
    else
      f[s]++;
  }
  for (typeof(f.begin()) it = f.begin(); it != f.end(); it++)
    v.push_back((*it).second);
  sort((v).begin(), (v).end());
  sort(p, p + n);
  int a = 0, b = 0;
  for (int i = (int)((v).size()) - 1; i >= 0; i--) {
    a += v[i] * p[(int)((v).size()) - 1 - i];
  }
  for (int i = (int)((v).size()) - 1; i >= 0; i--) {
    b += v[i] * p[n - ((int)((v).size()) - 1 - i) - 1];
  }
  cout << a << " " << b << endl;
}
