#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> price_vector;
  int price_fruit;
  for (int i = 0; i < n; ++i) {
    cin >> price_fruit;
    price_vector.push_back(price_fruit);
  }
  string fruit;
  map<string, int> fruit_map;
  for (int i = 0; i < m; ++i) {
    cin >> fruit;
    fruit_map[fruit]++;
  }
  vector<int> fruit_vector;
  for (const auto& m : fruit_map) fruit_vector.push_back(m.second);
  size_t count_min = 0;
  sort(fruit_vector.rbegin(), fruit_vector.rend());
  sort(price_vector.begin(), price_vector.end());
  for (size_t i = 0; i < fruit_vector.size(); ++i) {
    count_min += fruit_vector[i] * price_vector[i];
  }
  cout << count_min << ' ';
  size_t count_max = 0;
  sort(price_vector.rbegin(), price_vector.rend());
  for (size_t i = 0; i < fruit_vector.size(); ++i) {
    count_max += fruit_vector[i] * price_vector[i];
  }
  cout << count_max;
}
