#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, l = -1, max = 0, min = 0;
  cin >> n >> m;
  int price[n], c[m];
  char p[33], f[m][33];
  for (i = 0; i < n; i++) cin >> price[i];
  sort(price, price + n);
  for (i = 0; i < m; i++) {
    cin >> p;
    for (j = 0; j <= l; j++) {
      if (strcmp(f[j], p) == 0) {
        c[j]++;
        break;
      }
    }
    if (j > l) {
      l++;
      strcpy(f[l], p);
      c[l] = 1;
    }
  }
  sort(c, c + l + 1);
  i = 0;
  for (j = l; j >= 0; j--) {
    min += c[j] * price[i++];
    max += c[j] * price[--n];
  }
  cout << "\n" << min << " " << max;
  return 0;
}
