#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  map<string, int> fruits;
  for (int i = 0; i < m; ++i) {
    string fruit_name;
    cin >> fruit_name;
    fruits[fruit_name]++;
  }
  vector<int> x;
  for (pair<string, int> i : fruits) x.push_back(i.second);
  sort(x.begin(), x.end(), greater<int>());
  vector<int> min_set(x.size()), max_set(x.size());
  sort(a.begin(), a.end());
  copy(a.begin(), a.begin() + x.size(), min_set.begin());
  reverse(a.begin(), a.end());
  copy(a.begin(), a.begin() + x.size(), max_set.begin());
  int min_price = 0, max_price = 0;
  for (int i = 0; i < x.size(); ++i) {
    min_price += x[i] * min_set[i];
    max_price += x[i] * max_set[i];
  }
  cout << min_price << " " << max_price << endl;
}
