#include <bits/stdc++.h>
using namespace std;
int ToInt(string& s, int len) {
  int r = 0;
  for (int i = 0, max_ = (len); i < max_; ++i) {
    r *= 10;
    r += s[i] - '0';
  }
  return r;
}
int GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
int LCM(int a, int b) { return a * (b / GCD(a, b)); }
long long Pow(long long n, long long e) {
  if (e == 0) return 1;
  if (e == 1)
    return n;
  else if (e & 1) {
    long long t = Pow(n, e / 2);
    return n * t * t;
  } else {
    long long t = Pow(n, e / 2);
    return t * t;
  }
}
int v1[101], v2[101];
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  for (int i = 0, max_ = (N); i < max_; ++i) {
    scanf("%d", &v1[i]);
    v2[i] = v1[i];
  }
  sort(v1, v1 + N);
  sort(v2, v2 + N, greater<int>());
  map<string, int> m;
  string s;
  getline(cin, s);
  for (int i = 0, max_ = (M); i < max_; ++i) {
    getline(cin, s);
    ++m[s];
  }
  vector<int> v;
  auto it = m.begin();
  while (it != m.end()) {
    v.push_back(it->second);
    ++it;
  }
  sort((v).begin(), (v).end(), greater<int>());
  int min = 0, max = 0;
  for (int i = 0, max_ = ((int)(v).size()); i < max_; ++i) {
    min += v1[i] * v[i];
    max += v2[i] * v[i];
  }
  printf("%d %d\n", min, max);
  return 0;
}
