#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using mpii = map<int, int>;
using si = set<int>;
using sll = set<ll>;
using vll = vector<ll>;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int ar[n + 5];
  for (int i = 0; i <= n - 1; i++) scanf("%d", &ar[i]);
  sort(ar, ar + n);
  string str;
  map<string, int> mp;
  for (int i = 1; i <= m; i++) {
    cin >> str;
    mp[str]++;
  }
  vi vc;
  for (auto x : mp) {
    vc.push_back(x.second);
  }
  int mn = 0, mx = 0;
  sort(vc.begin(), vc.end(), greater<int>());
  for (int i = 0; i <= vc.size() - 1; i++) {
    mn += ar[i] * vc[i];
  }
  printf("%d", mn);
  printf(" ");
  reverse(ar, ar + n);
  for (int i = 0; i <= vc.size() - 1; i++) {
    mx += ar[i] * vc[i];
  }
  printf("%d", mx);
  printf("\n");
  return 0;
}
