#include <bits/stdc++.h>
using namespace std;
int sum_of_digits(long long int num) {
  if (num < 10) return num;
  int sum = 0;
  while (num > 0) {
    sum += num % 10;
    num = num / 10;
  }
  return sum_of_digits(sum);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }
  sort(a.begin(), a.end());
  map<string, int> s;
  for (int i = 0; i < m; i++) {
    string temp;
    cin >> temp;
    s[temp]++;
  }
  vector<int> values;
  for (auto it = s.begin(); it != s.end(); it++) {
    values.push_back(it->second);
  }
  sort(values.begin(), values.end());
  long long int min_price = 0, max_price = 0;
  for (int i = 0; i < values.size(); i++) {
    min_price += values[values.size() - 1 - i] * a[i];
    max_price += values[values.size() - 1 - i] * a[n - 1 - i];
  }
  cout << min_price << " " << max_price << endl;
}
