#include <bits/stdc++.h>
using namespace std;
map<string, int> f;
int n, m, a[102], b[102];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  std::sort(a, a + n);
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    f[s]++;
  }
  int k = 0;
  for (auto it = f.begin(); it != f.end(); it++) b[k++] = it->second;
  std::sort(b, b + k);
  int maxSum = 0, minSum = 0;
  for (int i = 0; i < k; i++)
    minSum += b[k - i - 1] * a[i], maxSum += b[k - i - 1] * a[n - i - 1];
  cout << minSum << " " << maxSum << '\n';
  return 0;
}
