#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, m, c = 0, j = 0, i = 0;
  string s;
  cin >> n >> m;
  int arr[n];
  vector<int> cnt(m, 1);
  string str[m];
  for (i = 0; i < n; i++) cin >> arr[i];
  for (i = 0; i < m; i++) cin >> str[i];
  for (i = 0; i < m; i++) {
    if (cnt[i]) {
      for (j = i + 1; j < m; j++) {
        if (str[i] == str[j]) {
          cnt[j] = 0;
          cnt[i]++;
        }
      }
    }
  }
  long long int a[m];
  for (i = 0; i < m; i++) a[i] = cnt[i];
  sort(a, a + m);
  sort(arr, arr + n);
  int pos = 0;
  int sum1 = 0, sum2 = 0;
  for (i = m - 1; i >= 0; i--) {
    if (a[i] == 0)
      break;
    else
      sum1 += a[i] * arr[pos];
    pos++;
    if (pos > n) break;
  }
  pos = n - 1;
  for (i = m - 1; i >= 0; i--) {
    if (a[i] == 0)
      break;
    else
      sum2 += a[i] * arr[pos];
    pos--;
    if (pos < 0) break;
  }
  cout << sum1 << " " << sum2 << endl;
}
