#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int min = 0, max = 0;
  sort(arr, arr + n);
  string s;
  unordered_map<string, int> mp;
  for (int i = 0; i < m; i++) {
    cin >> s;
    mp[s]++;
  }
  unordered_map<string, int>::iterator it;
  int index = 0;
  int helper[mp.size()];
  for (it = mp.begin(); it != mp.end(); it++) {
    helper[index] = it->second;
    index++;
  }
  sort(helper, helper + mp.size(), greater<int>());
  for (int i = 0; i < mp.size(); i++) {
    min += helper[i] * arr[i];
    max += helper[i] * arr[n - i - 1];
  }
  cout << min << " " << max << endl;
  return 0;
}
