#include <bits/stdc++.h>
using namespace std;
int w[100001];
int main() {
  map<string, int> mp;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  sort(w, w + n);
  string s;
  for (int i = 0; i < m; i++) {
    cin >> s;
    mp[s]++;
  }
  int a[101], k = 0;
  for (map<string, int>::iterator i = mp.begin(); i != mp.end(); i++) {
    a[k++] = (*i).second;
  }
  sort(a, a + k);
  long long s1 = 0, p = 0;
  for (int i = 0; i < k; i++) {
    s1 += a[k - i - 1] * w[i];
    p += a[k - i - 1] * w[n - i - 1];
  }
  cout << s1 << " " << p;
}
