#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const long long INF64 = 10000000000000000LL;
int n, m, a, b, t;
int price[128], cnt[128];
map<string, int> fruits;
string name;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> price[i];
  for (int i = 0; i < m; ++i) {
    cin >> name;
    ++fruits[name];
  }
  for (map<string, int>::iterator it = fruits.begin(); it != fruits.end(); ++it)
    cnt[t++] = it->second;
  sort(price, price + n);
  sort(cnt, cnt + t);
  for (int i = 0; i < t; ++i) {
    a += cnt[t - i - 1] * price[i];
    b += cnt[t - i - 1] * price[n - i - 1];
  }
  printf("%d %d\n", a, b);
  return 0;
}
