#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> c;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    c.push_back(a);
  }
  sort(c.begin(), c.end());
  map<string, int> f;
  for (int i = 0; i < m; i++) {
    string a;
    cin >> a;
    f[a]++;
  }
  vector<int> no;
  map<string, int>::const_iterator it = f.begin();
  for (int i = 0; i < m && it != f.end(); i++) {
    no.push_back(it->second);
    it++;
  }
  sort(no.begin(), no.end());
  long long sum = 0;
  int k = 0;
  for (int i = no.size() - 1; i >= 0; i--) {
    sum += no[i] * c[k];
    k++;
  }
  cout << sum << " ";
  sum = 0;
  k = c.size() - 1;
  for (int i = no.size() - 1; i >= 0; i--) {
    sum += no[i] * c[k];
    k--;
  }
  cout << sum << " ";
}
