#include <bits/stdc++.h>
using namespace std;
bool malejaca(int i, int j) { return (i > j); }
int GetFruitsArr(int fr[], vector<string> s) {
  int curr, temp = 1, j = 0, k = 0;
  bool was = false;
  for (int i = 0; i < s.capacity(); i++) {
    curr = i;
    if (i > 0)
      if (s[i].compare(s[i - 1]) == 0) continue;
    for (int j = curr + 1; j < s.capacity(); j++) {
      if (s[j].compare(s[curr]) == 0) {
        temp++;
        fr[k] = temp;
      }
    }
    if (temp == 1) fr[k] = 1;
    k++;
    temp = 1;
  }
  return k;
}
int FindSums(int fr[], int tags[], int ind) {
  int sum = 0;
  for (int i = 0; i < ind; i++) {
    sum += fr[i] * tags[i];
  }
  return sum;
}
int main() {
  int n, *tags, *frarr, f, minp, maxp, ind;
  vector<string> fruits;
  string s;
  cin >> n >> f;
  tags = new int[n];
  frarr = new int[101];
  for (int i = 0; i < n; i++) cin >> tags[i];
  for (int i = 0; i < f; i++) {
    cin >> s;
    fruits.push_back(s);
  }
  sort(fruits.begin(), fruits.end());
  ind = GetFruitsArr(frarr, fruits);
  sort(tags, tags + n);
  sort(frarr, frarr + ind, malejaca);
  minp = FindSums(frarr, tags, ind);
  sort(tags, tags + n, malejaca);
  maxp = FindSums(frarr, tags, ind);
  cout << minp << " " << maxp << endl;
  return 0;
}
