#include <bits/stdc++.h>
using namespace std;
const int MAX = 128;
int n, m, k;
int price[MAX];
map<string, int> quant;
int q[MAX];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> price[i];
  for (int i = 0; i < m; i++) {
    string str;
    cin >> str;
    quant[str]++;
  }
  sort(price, price + n);
  for (map<string, int>::iterator it = quant.begin(); it != quant.end(); ++it) {
    q[k++] = it->second;
  }
  sort(q, q + k);
  reverse(q, q + k);
  int cmin = 0, cmax = 0;
  for (int i = 0; i < k; i++) {
    cmin += price[i] * q[i];
    cmax += price[n - 1 - i] * q[i];
  }
  printf("%d %d\n", cmin, cmax);
  return 0;
}
