#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int b[N], a[N];
map<string, int> mp;
int main() {
  string s;
  int n, m;
  int l;
  int maxn, minn;
  while (cin >> n >> m) {
    maxn = minn = 0;
    mp.clear();
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for (int i = 0; i < m; i++) {
      cin >> s;
      mp[s]++;
    }
    l = 0;
    for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++)
      b[l++] = it->second;
    sort(b, b + l);
    for (int i = 0; i < l; i++) {
      minn += a[i] * b[l - i - 1];
      maxn += b[i] * a[n - l + i];
    }
    cout << minn << " " << maxn << endl;
  }
  return 0;
}
