#include <bits/stdc++.h>
void f(int a[], int m, int n) {
  int x = a[m], i = m, j = n;
  if (m > n) return;
  while (i < j) {
    while (i < j && a[j] >= x) j--;
    a[i] = a[j];
    while (i < j && a[i] <= x) i++;
    a[j] = a[i];
  }
  a[i] = x;
  f(a, m, i - 1);
  f(a, i + 1, n);
}
int main() {
  int j, a[1000], t, i, m, n, b[1000], x, y, t1;
  char c[200][100], c1[100];
  while (scanf("%d%d", &m, &n) != EOF) {
    for (i = 1; i <= m; ++i) scanf("%d", &a[i]);
    for (i = 1; i <= n; ++i) scanf("%s", c[i]);
    f(a, 1, m);
    for (j = 1; j < n; ++j) {
      for (i = 1; i <= n - j; ++i)
        if (strcmp(c[i + 1], c[i]) > 0) {
          strcpy(c1, c[i]);
          strcpy(c[i], c[i + 1]);
          strcpy(c[i + 1], c1);
        }
    }
    t = 1;
    b[1] = 1;
    for (i = 2; i <= n; ++i) {
      if (strcmp(c[i], c[i - 1]) == 0)
        b[t]++;
      else {
        t++;
        b[t] = 1;
      }
    }
    f(b, 1, t);
    x = 0;
    y = 0;
    t1 = 1;
    for (i = t, j = m; i >= 1; --i, --j) {
      x = x + b[i] * a[t1++];
      y += b[i] * a[j];
    }
    printf("%d %d\n", x, y);
  }
  return 0;
}
