#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, m, a[maxn], b[maxn], id;
map<string, int> mapp;
int ID(string s) {
  if (mapp[s] != 0)
    return mapp[s];
  else
    return mapp[s] = id++;
}
bool cmp(int a, int b) { return a > b; }
int main() {
  id = 1;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  for (int i = 0; i < m; i++) {
    cin >> s;
    b[ID(s)]++;
  }
  sort(b + 1, b + id + 1, cmp);
  sort(a, a + n);
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < id; i++)
    ans1 += a[i] * b[i + 1], ans2 += a[n - 1 - i] * b[i + 1];
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
