#include <bits/stdc++.h>
using namespace std;
int a[110], b[110];
int main() {
  int n, m, cnt = 0;
  map<string, int> f;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  string s;
  for (int i = 0; i < m; i++) {
    cin >> s;
    if (f[s] == 0)
      f[s] = cnt + 1, b[cnt++] = 1;
    else
      b[f[s] - 1]++;
  }
  sort(b, b + cnt);
  int minans = 0, maxans = 0;
  for (int i = 0; i < cnt; i++)
    minans += a[i] * b[cnt - i - 1], maxans += b[cnt - i - 1] * a[n - i - 1];
  cout << minans << " " << maxans << endl;
  return 0;
}
