#include <bits/stdc++.h>
using namespace std;
int F[101], U[101], n, k = 1, a, b, m;
map<string, int> C;
string O;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> F[i];
  while (m--) cin >> O, ++C[O];
  sort(F, F + n + 1);
  for (map<string, int>::iterator i = C.begin(); i != C.end(); i++)
    U[k++] = i->second;
  sort(U, U + C.size() + 1);
  for (int i = --k, j = n, l = 1; i >= 1; i--, j--, l++)
    b += U[i] * F[j], a += U[i] * F[l];
  cout << a << " " << b;
}
