#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  for (int &i : v) cin >> i;
  map<string, int> mp;
  for (int i = 0; i < m; i++) {
    string x;
    cin >> x;
    mp[x]++;
  }
  sort(v.begin(), v.end());
  vector<int> v1;
  for (auto [f, s] : mp) v1.push_back(s);
  sort(v1.begin(), v1.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == v1.size()) break;
    ans += v1[i] * v[i];
  }
  cout << ans << " ";
  reverse(v.begin(), v.end());
  ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == v1.size()) break;
    ans += v1[i] * v[i];
  }
  cout << ans << endl;
  return 0;
}
