#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n], i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<string> fruits;
  string fr;
  for (i = 0; i < m; i++) {
    cin >> fr;
    fruits.push_back(fr);
  }
  vector<string> sf(fruits.begin(), fruits.end());
  sort(sf.begin(), sf.end());
  sf.erase(unique(sf.begin(), sf.end()), sf.end());
  vector<int> num;
  for (i = 0; i < sf.size(); i++) {
    num.push_back(count(fruits.begin(), fruits.end(), sf[i]));
  }
  sort(num.begin(), num.end());
  int sum = 0, sum2 = 0;
  sort(a, a + n);
  j = n - 1;
  int k = 0;
  for (i = num.size() - 1; i >= 0; i--) {
    sum += num[i] * a[j];
    j--;
    sum2 += a[k] * num[i];
    k++;
  }
  cout << sum2 << " " << sum;
  return 0;
}
