#include <bits/stdc++.h>
using namespace std;
int f[100], c, p[100];
map<string, int> mp;
int idx(string &s) {
  if (mp.find(s) == mp.end()) return mp[s] = c++;
  return mp[s];
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> p[i];
  sort(p, p + n);
  string s;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    ++f[idx(s)];
  }
  sort(f, f + c);
  int a = 0, b = 0;
  for (int i = 0; i < c; ++i) {
    a += p[c - i - 1] * f[i];
    b += p[n - i - 1] * f[c - i - 1];
  }
  cout << a << " " << b << endl;
  return 0;
}
