#include <bits/stdc++.h>
using namespace std;
void doublade() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
}
bool comp(long long a, long long b) { return (a > b); }
int main() {
  doublade();
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  map<string, long long> f;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < m; i++) {
    string s;
    cin >> s;
    f[s] += 1;
  }
  vector<long long> b;
  for (auto it = f.begin(); it != f.end(); it++) {
    b.push_back(it->second);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(), comp);
  long long mini = 0, maxi = 0;
  for (long long i = 0; i < b.size(); i++) {
    mini += b[i] * a[i];
  }
  sort(a.begin(), a.end(), comp);
  for (long long i = 0; i < b.size(); i++) {
    maxi += b[i] * a[i];
  }
  cout << mini << " " << maxi << "\n";
  return 0;
}
