#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int costs[n];
  for (int j = 0; j < n; j++) {
    cin >> costs[j];
  }
  string fruits[m];
  for (int i = 0; i < m; i++) {
    cin >> fruits[i];
  }
  int arr[100];
  int d = 0;
  for (int p = 0; p < m; p++) {
    int c;
    if (fruits[p] != "-1") {
      c = 1;
      for (int q = p + 1; q < m; q++) {
        if (fruits[p] == fruits[q]) {
          c++;
          fruits[q] = "-1";
        }
      }
      arr[d++] = c;
    }
  }
  sort(costs, costs + n);
  sort(arr, arr + d);
  int minsum = 0;
  int maxsum = 0;
  for (int x = 0; x < n && x < d; x++) {
    minsum = minsum + (costs[x] * arr[d - 1 - x]);
    maxsum = maxsum + (costs[n - 1 - x] * arr[d - 1 - x]);
  }
  cout << minsum << " " << maxsum;
  return 0;
}
