#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<string, int> &a, const pair<string, int> &b) {
  return a.second > b.second;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> prices;
  prices.assign(n, int());
  for (int i = 0; i < n; i++) {
    scanf("%d", &prices[i]);
  }
  string s;
  getline(cin, s);
  sort(prices.begin(), prices.end());
  vector<pair<string, int> > fruits_vector;
  map<string, int> fruits;
  for (int i = 0; i < m; i++) {
    string fruit;
    getline(cin, fruit);
    fruits[fruit.c_str()]++;
  }
  for (map<string, int>::iterator it = fruits.begin(); it != fruits.end();
       it++) {
    fruits_vector.push_back(make_pair(it->first, it->second));
  }
  sort(fruits_vector.begin(), fruits_vector.end(), cmp);
  int j = 0;
  int minimum = 0, maximum = 0;
  for (int i = 0; i < (int)fruits_vector.size() && j < (int)prices.size();
       i++, j++) {
    minimum += fruits_vector[i].second * prices[j];
    maximum += fruits_vector[i].second * prices[(int)prices.size() - 1 - j];
  }
  printf("%d %d\n", minimum, maximum);
  return 0;
}
