#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const long long inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double PI = 3.14159265358929;
map<string, int> f;
int cost[128];
int _count[128];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> cost[i];
  sort(cost, cost + n);
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    f[s]++;
  }
  int j = 0;
  for (map<string, int>::iterator i = f.begin(); i != f.end(); i++, j++) {
    _count[j] += i->second;
    {};
  }
  sort(_count, _count + j);
  int amin, amax;
  amin = amax = 0;
  for (int i = j - 1; i >= 0; i--) {
    amin += _count[i] * cost[-(i - j + 1)];
    amax += _count[i] * cost[n - 1 + (i - j + 1)];
    {};
  }
  cout << amin << ' ' << amax << endl;
  return 0;
}
