#include <bits/stdc++.h>
using namespace std;
int getint() {
  int ans = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + c - '0';
    c = getchar();
  }
  return ans * f;
}
map<string, int> mp;
int cnt[110], pri[110];
int main() {
  int n = getint(), m = getint();
  for (int i = 0; i < n; i++) pri[i] = getint();
  sort(pri, pri + n);
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int t = 0;
  for (auto i : mp) cnt[t++] = i.second;
  m = mp.size();
  sort(cnt, cnt + m);
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < m; i++) {
    ans1 += cnt[i] * pri[m - i - 1];
  }
  for (int i = 0; i < m; i++) {
    ans2 += cnt[i] * pri[n - m + i];
  }
  cout << ans1 << " " << ans2 << " " << endl;
  return 0;
}
