#include <bits/stdc++.h>
using namespace std;
struct node {
  string str;
  int num;
};
int compare(const void *p1, const void *p2) {
  const node *elem1 = (node *)p1;
  const node *elem2 = (node *)p2;
  if (elem1->num < elem2->num)
    return -1;
  else if (elem1->num > elem2->num)
    return 1;
  else
    return 0;
}
int main() {
  int sum = 0;
  int add = 0;
  string s;
  int n, m, i, d, j;
  cin >> n >> m;
  int *q = new int[n];
  for (i = 0; i < n; i++) {
    cin >> q[i];
  }
  node *p = new node[m];
  cin >> s;
  p[0].str = s;
  p[0].num = 1;
  int k = 1;
  for (i = 1; i < m; i++) {
    cin >> s;
    d = 1;
    for (j = 0; j < k; j++) {
      if (s == p[j].str) {
        p[j].num++;
        d = 0;
        break;
      }
    }
    if (d == 1) {
      p[k].str = s;
      p[k].num = 1;
      k++;
    }
  }
  qsort(p, k, sizeof(node), compare);
  sort(q, q + n);
  for (i = 0; i < k; i++) {
    sum += q[i] * (p[k - 1 - i].num);
  }
  int h = k - 1;
  for (i = n - 1; i >= n - k; i--) {
    add += q[i] * (p[h].num);
    h--;
  }
  cout << sum << " " << add << endl;
  return 0;
}
