#include <bits/stdc++.h>
using namespace std;
class snc {
 public:
  int sz;
  int num;
  string* reverse;
  map<string, int> forward;
  snc(const int& n) {
    sz = n;
    num = 0;
    reverse = new string[n];
  }
  void addS(const string& s) {
    assert(num < sz);
    assert(forward.find(s) == forward.end());
    reverse[num] = s;
    forward[s] = num;
    num++;
  }
  int getN(const string& s) {
    map<string, int>::iterator it = forward.find(s);
    assert(it != forward.end());
    return it->second;
  }
  string getS(const int& n) {
    assert(n < num);
    return reverse[n];
  }
  bool isIn(const string& s) { return forward.find(s) != forward.end(); }
  int numE() { return num; }
};
int main() {
  int n, m;
  cin >> n >> m;
  snc dict(n);
  int pt[n];
  for (int i = 0; i < n; ++i) cin >> pt[i];
  sort(pt, pt + n);
  int codes[m];
  for (int i = 0; i < m; ++i) {
    string name;
    cin >> name;
    if (!dict.isIn(name)) dict.addS(name);
    codes[i] = dict.getN(name);
  }
  sort(codes, codes + m);
  int freq[n];
  for (int i = 0; i < n; ++i) {
    pair<int*, int*> p = equal_range(codes, codes + m, i);
    freq[i] = p.second - p.first;
  }
  sort(freq, freq + n);
  int ansu = inner_product(freq, freq + n, pt, 0);
  reverse(freq, freq + n);
  int ansl = inner_product(freq, freq + n, pt, 0);
  cout << ansl << " " << ansu << endl;
}
