#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <class T>
T gcd(T a, T b) {
  for (T c; b; c = a, a = b, b = c % b)
    ;
  return a;
}
template <class T>
void out(const vector<T> &a) {
  for (int i = 0; i < ((int)(a).size()); ++i) cout << a[i] << " ";
  cout << endl;
}
int countbit(int n) { return n == 0 ? 0 : 1 + countbit(n & (n - 1)); }
const int d8[8][2] = {{1, 0}, {-1, 0},  {0, 1},  {0, -1},
                      {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};
const int d4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
inline int dcmp(double x) { return (x > EPS) - (x < -EPS); }
inline double cross(const complex<double> &a, const complex<double> &b) {
  return (conj(a) * b).imag();
}
inline double dot(const complex<double> &a, const complex<double> &b) {
  return (conj(a) * b).real();
}
int a[100];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  sort(a, a + n);
  map<string, int> ma;
  while (m--) {
    char buf[100];
    scanf("%s", buf);
    ma[string(buf)]++;
  }
  vector<int> b;
  for (map<string, int>::iterator it = ma.begin(); it != ma.end(); ++it)
    b.push_back(it->second);
  sort(b.begin(), b.end());
  int sum = 0;
  for (int i = 0; i < ((int)(b).size()); ++i)
    sum += a[((int)(b).size()) - 1 - i] * b[i];
  printf("%d ", sum);
  sum = 0;
  sort(a, a + n, greater<int>());
  for (int i = 0; i < ((int)(b).size()); ++i)
    sum += a[i] * b[((int)(b).size()) - 1 - i];
  printf("%d\n", sum);
  return 0;
}
