#include <bits/stdc++.h>
using namespace std;
string s;
map<string, int> m;
int a[10000];
vector<string> v;
vector<int> u;
int main() {
  int n, m1;
  cin >> n >> m1;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(&a[1], &a[n + 1]);
  for (int i = 1; i <= m1; i++) {
    cin >> s;
    m[s]++;
    if (m[s] == 1) {
      v.push_back(s);
    }
  }
  for (int i = 0; i < v.size(); i++) {
    u.push_back(m[v[i]]);
  }
  long long int mx = 0, mn = 0;
  sort(u.begin(), u.end());
  int now = n;
  int now2 = 1;
  for (int i = u.size() - 1; i >= 0; i--) {
    mx += (u[i] * a[now]);
    mn += (u[i] * a[now2]);
    now--;
    now2++;
  }
  cout << mn << " " << mx << endl;
  return 0;
}
