#include <bits/stdc++.h>
using namespace std;
int n, m;
int price[105];
char str[50];
map<string, int> mep;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < (int)n; ++i) scanf("%d", &price[i]);
  sort(price, price + n);
  for (int i = 0; i < (int)m; ++i) {
    scanf("%s", str);
    mep[(string)str]++;
  }
  vector<int> lho;
  for (__typeof((mep).begin()) it = (mep).begin(); it != (mep).end(); ++it)
    lho.push_back(it->second);
  sort((lho).begin(), (lho).end());
  int a = 0, b = n - 1;
  int murah = 0, mahal = 0;
  for (int i = (int)lho.size() - 1; i >= (int)0; --i) {
    murah += price[a] * lho[i];
    mahal += price[b] * lho[i];
    ++a;
    --b;
  }
  printf("%d %d\n", murah, mahal);
  return 0;
}
