#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m;
  cin >> n >> m;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  string s;
  map<string, long long int> mp;
  for (long long int i = 0; i < m; i++) {
    cin >> s;
    mp[s]++;
  }
  vector<long long int> v;
  for (auto it : mp) v.push_back(it.second);
  m = v.size();
  sort(arr, arr + n);
  sort(v.begin(), v.end(), greater<long long int>());
  long long int a = 0, b = 0;
  for (long long int i = 0; i < m; i++) a += v[i] * arr[i];
  reverse(arr, arr + n);
  for (long long int i = 0; i < m; i++) b += v[i] * arr[i];
  cout << a << " " << b;
}
