#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  map<string, int> mp;
  map<string, int> mp2;
  int n, m, maxsum = 0, minsum = 0;
  cin >> n >> m;
  string s[m];
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < m; i++) {
    cin >> s[i];
    mp[s[i]]++;
  }
  for (int i = 0; i < m; i++) {
    if (mp2[s[i]] == 0) v.push_back(mp[s[i]]);
    mp2[s[i]]++;
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < v.size(); i++) {
    minsum += a[i] * v[i];
  }
  reverse(a, a + n);
  for (int i = 0; i < v.size(); i++) {
    maxsum += a[i] * v[i];
  }
  cout << minsum << " " << maxsum;
}
