#include <bits/stdc++.h>
using namespace std;
const int MAX = 110;
vector<int> v;
map<string, int> mp;
int a[MAX];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    int tmp = it->second;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  long long ans1 = 0, ans2 = 0;
  int t = 0;
  for (int i = v.size() - 1; i >= 0; i--) {
    ans1 += a[t] * v[i];
    t++;
  }
  t = n - 1;
  for (int i = v.size() - 1; i >= 0; i--) {
    ans2 += v[i] * a[t];
    t--;
  }
  cout << ans1 << " " << ans2;
}
