#include <bits/stdc++.h>
using namespace std;
const int N = 100000, M = 100000;
template <typename T>
inline T sqr(T t) {
  return t * t;
}
void file() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
string s;
vector<int> v, ans;
map<string, int> mp;
long long n, m, k, i, a[N], mn, go, Amn, Amx;
int main() {
  Amn = 0;
  Amx = 0;
  file();
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  getline(cin, s);
  for (int i = 1; i <= m; i++) {
    getline(cin, s);
    if (mp[s] == 0) mn++;
    mp[s]++;
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= mn; i++) v.push_back(a[i]);
  sort(v.begin(), v.end());
  for (map<string, int>::iterator i = mp.begin(); i != mp.end(); i++)
    ans.push_back(i->second);
  sort(ans.begin(), ans.end());
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < v.size(); i++) Amn += v[i] * ans[i];
  reverse(a + 1, a + 1 + n);
  v.clear();
  for (int i = 1; i <= mn; i++) v.push_back(a[i]);
  for (int i = 0; i < v.size(); i++) Amx += v[i] * ans[i];
  cout << Amn << " " << Amx;
}
