#include <bits/stdc++.h>
using namespace std;
const long long M = 2e5 + 9, MOD = 1e9 + 7;
int a[M], b[M];
map<string, int> mp;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  while (m--) {
    cin >> s;
    mp[s]++;
  }
  int i = 0;
  for (auto x : mp) {
    b[i] = x.second;
    i++;
  }
  sort(b, b + i);
  int maximum = 0, minimum = 0, k = 0, c = n - 1;
  for (int j = i - 1; j >= 0 && k < n; j--) {
    minimum += b[j] * a[k];
    maximum += b[j] * a[c];
    k++;
    c--;
  }
  cout << minimum << " " << maximum << endl;
  return 0;
}
