#include <bits/stdc++.h>
using namespace std;
int a[120];
string s;
int main() {
  int n, m;
  map<string, int> mmap, mmap2;
  map<string, int>::iterator it;
  map<string, int>::iterator itmax;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= m; i++) {
    cin >> s;
    if (mmap.find(s) == mmap.end()) {
      mmap[s] = 1;
    } else
      mmap[s]++;
  }
  mmap2 = mmap;
  int num = mmap.size();
  int least = 0;
  for (int i = 1; i <= num; i++) {
    itmax = mmap.begin();
    for (it = mmap.begin(); it != mmap.end(); it++) {
      if (it->second > itmax->second) itmax = it;
    }
    least += itmax->second * a[i];
    mmap.erase(itmax);
  }
  int maxx = 0;
  for (int i = n; i > n - num; i--) {
    itmax = mmap2.begin();
    for (it = mmap2.begin(); it != mmap2.end(); it++) {
      if (it->second > itmax->second) itmax = it;
    }
    maxx += itmax->second * a[i];
    mmap2.erase(itmax);
  }
  cout << least << " " << maxx << endl;
  return 0;
}
