#include <bits/stdc++.h>
using namespace std;
map<string, int> p;
string s;
int a[101010];
bool cmp(const pair<string, int>& a, const pair<string, int>& b) {
  return a.second < b.second;
}
int main() {
  int n, r;
  scanf("%d %d", &n, &r);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  sort(a, a + n);
  for (int i = 0; i < r; i++) {
    cin >> s;
    p[s]++;
  }
  vector<pair<string, int>> vec(p.begin(), p.end());
  sort(vec.begin(), vec.end(), cmp);
  int min = 0, max = 0, j = 0;
  for (int i = vec.size() - 1; i >= 0; i--) {
    min += vec[i].second * a[j++];
  }
  j = n - 1;
  for (int i = vec.size() - 1; i >= 0; i--) {
    max += vec[i].second * a[j--];
  }
  cout << min << " " << max << endl;
  return 0;
}
