#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> prices(n), ans;
  for (int i = 0; i < n; ++i) cin >> prices[i];
  map<string, int> f;
  string s;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    f[s]++;
  }
  for (auto i : f) {
    ans.push_back(i.second);
  }
  sort(ans.begin(), ans.end());
  sort(prices.begin(), prices.end());
  int a = 0, b = 0, x = (int)ans.size();
  for (int i = 0; i < x; ++i) {
    a += prices[i] * ans[x - i - 1];
    b += prices[n - i - 1] * ans[x - i - 1];
  }
  cout << a << " " << b;
  return 0;
}
