#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  int T = 1;
  int cases = 0;
  while (T--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    map<string, int> b;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < m; i++) {
      string s;
      cin >> s;
      b[s]++;
    }
    vector<int> c;
    for (auto &i : b) {
      c.push_back(i.second);
    }
    sort(c.rbegin(), c.rend());
    int Min = 0, Max = 0;
    int p = c.size();
    for (int i = 0; i < p; i++) {
      Min += a[i] * c[i];
    }
    reverse(a.begin(), a.end());
    for (int i = 0; i < p; i++) {
      Max += a[i] * c[i];
    }
    cout << Min << " " << Max << endl;
  }
}
