#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N];
string na[N];
int k = 0;
struct fruits {
  string name;
  int num;
} f[N];
bool cmp(struct fruits x, struct fruits y) { return x.num > y.num; }
int main() {
  int n, m;
  int res_min = 0, res_max = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; i++) {
    cin >> na[i];
  }
  sort(na, na + m);
  f[k].name = na[0];
  f[k].num = 1;
  for (int i = 1; i < m; i++) {
    if (na[i] != na[i - 1]) {
      k++;
      f[k].name = na[i];
      f[k].num = 1;
    } else {
      f[k].num++;
    }
  }
  sort(a, a + n);
  sort(f, f + k + 1, cmp);
  for (int i = 0; i <= k; i++) {
    res_min += a[i] * f[i].num;
  }
  for (int i = 0; i <= k; i++) {
    res_max += a[n - i - 1] * f[i].num;
  }
  cout << res_min << " " << res_max << endl;
  return 0;
}
