#include <bits/stdc++.h>
using namespace std;
void merge(int *arr, int l, int m, int r) {
  int n1 = m - l + 1;
  int n2 = r - m;
  int *left = (int *)malloc(n1 * sizeof(int));
  int *right = (int *)malloc(n2 * sizeof(int));
  for (int i = 0; i < n1; i++) left[i] = arr[l + i];
  for (int i = 0; i < n2; i++) right[i] = arr[m + 1 + i];
  int i = 0, j = 0, k = l;
  while (i < n1 && j < n2) {
    if (left[i] <= right[j]) {
      arr[k] = left[i];
      i++;
    } else {
      arr[k] = right[j];
      j++;
    }
    k++;
  }
  while (i < n1) {
    arr[k] = left[i];
    i++;
    k++;
  }
  while (j < n2) {
    arr[k] = right[j];
    j++;
    k++;
  }
  free(left);
  free(right);
}
void merge_sort(int *arr, int l, int r) {
  if (l < r) {
    int m = (l + r) / 2;
    merge_sort(arr, l, m);
    merge_sort(arr, m + 1, r);
    merge(arr, l, m, r);
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  int *a = (int *)malloc(n * sizeof(int));
  map<string, int> m;
  vector<int> v;
  for (int i = 0; i < n; i++) cin >> a[i];
  int cmax = 0;
  for (int i = 0; i < k; i++) {
    string s1;
    cin >> s1;
    m[s1]++;
    if (cmax == 0) {
      cmax = m[s1];
      v.push_back(1);
    } else if (cmax < m[s1]) {
      cmax = m[s1];
      v.push_back(1);
      v[cmax - 2]--;
    } else if (m[s1] > 1) {
      v[m[s1] - 1]++;
      v[m[s1] - 2]--;
    } else if (m[s1] == 1) {
      v[0]++;
    }
  }
  merge_sort(a, 0, n - 1);
  int mincost = 0, maxcost = 0;
  int j = 0;
  for (int i = v.size() - 1; i >= 0; i--) {
    while (v[i] > 0) {
      mincost += a[j] * (i + 1);
      maxcost += a[n - j - 1] * (i + 1);
      j++;
      v[i]--;
    }
  }
  cout << mincost << " " << maxcost;
  free(a);
  return 0;
}
