#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<string, int> a, pair<string, int> b) {
  return a.second > b.second;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    int price[n];
    string fruit;
    map<string, int> List;
    for (int i = 0; i < n; i++) cin >> price[i];
    for (int i = 0; i < m; i++) {
      cin >> fruit;
      List[fruit] += 1;
    }
    sort(&price[0], &price[n]);
    int k = 0, mini = 0, maxx = 0;
    vector<pair<string, int> > newList(List.begin(), List.end());
    sort(newList.begin(), newList.end(), cmp);
    for (auto x : newList) {
      mini += (x.second * price[k]);
      maxx += (x.second * price[n - k - 1]);
      k++;
    }
    cout << mini << " " << maxx << "\n";
  }
}
