#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int x = 0, y = 0;
  vector<int> b;
  map<string, int> mp;
  map<string, int>::iterator it;
  string str;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> str;
    mp[str]++;
  }
  for (it = mp.begin(); it != mp.end(); it++) {
    b.push_back(it->second);
  }
  sort(b.begin(), b.end(), greater<int>());
  sort(a.begin(), a.end());
  for (int i = 0; i < b.size(); i++) {
    x += a[i] * b[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < b.size(); i++) {
    y += a[i] * b[i];
  }
  cout << x << ' ' << y;
  return 0;
}
