#include <bits/stdc++.h>
using namespace std;
int n, m;
int b[110], bn;
int p[110];
void input() {
  char c[110][110];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", p + i);
  for (int i = 0; i < m; i++) scanf("%s", c[i]);
  bn = 0;
  int vis[110];
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < m; i++) {
    if (vis[i]) continue;
    int ct = 1;
    for (int j = i + 1; j < m; j++)
      if (strcmp(c[i], c[j]) == 0) vis[j] = 1, ct++;
    b[bn++] = ct;
  }
}
void solve() {
  sort(b, b + bn);
  sort(p, p + n);
  int mn = 0, mx = 0;
  for (int i = 0; i < bn; i++) mn += b[bn - i - 1] * p[i];
  for (int i = 0; i < bn; i++) mx += b[bn - i - 1] * p[n - i - 1];
  printf("%d %d\n", mn, mx);
}
int main() {
  input();
  solve();
  return 0;
}
