#include <bits/stdc++.h>
using namespace std;
struct pt {
  string a;
  int cnt;
};
bool comp(pt a, pt b) { return a.cnt < b.cnt; }
int w[101];
string s[101];
map<string, int> mp;
pt z[101];
int main() {
  int n, m, t = 0, mn = 0, mx = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i <= m; i++) cin >> s[i], mp[s[i]]++;
  sort(w + 1, w + n + 1);
  for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++)
    z[++t].a = (*it).first, z[t].cnt = (*it).second;
  sort(z + 1, z + t + 1, comp);
  int id = 1;
  for (int i = t; i >= 1; i--) mn += w[id++] * z[i].cnt;
  id = t;
  for (int i = n; id >= 1; i--) mx += w[i] * z[id--].cnt;
  cout << mn << " " << mx;
}
