#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
bool cmp(char i, char j) { return i >= j; }
int main() {
  int n, m, a[200], k = 0, minn = 0, maxx = 0, b[110];
  string ss[110], s1[110];
  map<string, int> p;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    p[s] = 0;
    s1[i] = s;
    s.clear();
  }
  for (int i = 0; i < m; i++) {
    if (!p[s1[i]]) {
      ss[k] = s1[i];
      k++;
    }
    p[s1[i]]++;
  }
  for (int i = 0; i < k; i++) b[i] = p[ss[i]];
  sort(b, b + k, cmp);
  for (int i = 0; i < k; i++) {
    minn += b[i] * a[i];
    maxx += b[i] * a[n - i - 1];
  }
  cout << minn << " " << maxx << endl;
  return 0;
}
