#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long n, m;
  cin >> n >> m;
  long ar[1005] = {0}, a[10005] = {0};
  for (int i = 0; i < n; i++) cin >> ar[i];
  map<string, int> mp;
  map<string, int>::iterator it;
  string s;
  for (int j = 0; j < m; j++) {
    cin >> s;
    mp[s]++;
  }
  long p = 0;
  for (it = mp.begin(); it != mp.end(); it++) {
    a[p++] = it->second;
  }
  sort(a, a + p);
  sort(ar, ar + n);
  long long mn = 0, t = 0;
  for (int i = p - 1; i >= 0; i--) {
    mn += (a[i] * ar[t]);
    t++;
  }
  long long tt = n - 1, mx = 0;
  for (int i = p - 1; i >= 0; i--) {
    mx += (a[i] * ar[tt]);
    tt--;
  }
  cout << mn << " " << mx << endl;
  return 0;
}
