#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int a[n], b[m];
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  map<string, int> mp;
  for (int i = 0; i < m; ++i) {
    string pp;
    cin >> pp;
    ++mp[pp];
  }
  int l = 0, sz = mp.size(), o[sz], MIN = 0, MAX = 0, y = 0;
  for (auto i : mp) {
    o[l++] = i.second;
  }
  sort(o, o + sz);
  for (int i = sz - 1; i >= 0; --i) {
    MIN += o[i] * a[y++];
    MAX += o[i] * a[--n];
  }
  cout << MIN << " " << MAX << "\n";
  return 0;
}
