#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
void file() {
  freopen("B-large.in", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void play() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
}
int main() {
  play();
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  map<string, int> cntt;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    cntt[s]++;
  }
  vector<int> cnt;
  for (auto it = cntt.begin(); it != cntt.end(); ++it)
    cnt.push_back(it->second);
  sort(((cnt).begin()), ((cnt).end()));
  reverse(((cnt).begin()), ((cnt).end()));
  sort(((v).begin()), ((v).end()));
  int mn = 0, mx = 0;
  for (int i = 0; i < ((int)((cnt).size())); i++) mn += v[i] * cnt[i];
  reverse(((v).begin()), ((v).end()));
  for (int i = 0; i < ((int)((cnt).size())); i++) mx += v[i] * cnt[i];
  cout << mn << " " << mx << endl;
  return 0;
}
