#include <bits/stdc++.h>
using namespace std;
int price[102];
unordered_map<string, int> freq;
bool cmp_fruit(pair<string, int> p1, pair<string, int> p2) {
  return p1.second > p2.second;
}
bool cmp_price(int val1, int val2) { return val1 > val2; }
int main() {
  int n, m, p;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &price[i]);
  }
  getchar();
  string item;
  for (int i = 0; i < m; i++) {
    cin >> item;
    freq[item]++;
  }
  vector<pair<string, int> > fruits;
  for (auto p : freq) {
    fruits.push_back({p.first, p.second});
  }
  sort(fruits.begin(), fruits.end(), cmp_fruit);
  sort(price, price + n);
  int idx = 0;
  int min_total_cost = 0;
  for (int i = 0; i < fruits.size(); i++) {
    min_total_cost += price[idx] * fruits[i].second;
    idx++;
  }
  sort(price, price + n, cmp_price);
  idx = 0;
  int max_total_cost = 0;
  for (int i = 0; i < fruits.size(); i++, idx++) {
    max_total_cost += price[idx] * fruits[i].second;
  }
  printf("%d %d\n", min_total_cost, max_total_cost);
  return 0;
}
