#include <bits/stdc++.h>
using namespace std;
int n, m, pr[128], ls[128];
string f;
map<string, int> mp;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> pr[i];
  for (int i = 0; i < m; ++i) cin >> f, ++mp[f];
  m = 0;
  for (auto it : mp) ls[m++] = it.second;
  sort(ls, ls + m, greater<int>()), sort(pr, pr + n);
  int a = 0, b = 0;
  for (int i = 0; i < m; ++i) a += ls[i] * pr[i], b += ls[i] * pr[n - 1 - i];
  cout << a << ' ' << b << '\n';
}
