#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) {
    solve();
    cout << "\n";
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << "secs"
       << "\n";
  return 0;
}
void solve() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v(n);
  vector<string> y(m);
  for (int i = 0; i < (n); ++i) cin >> v[i];
  for (int i = 0; i < (m); ++i) cin >> y[i];
  unordered_map<string, int> q;
  for (int i = 0; i < (m); ++i) q[y[i]]++;
  sort(v.begin(), v.end());
  vector<long long int> x;
  long long int min = 0;
  long long int max = 0;
  for (auto fruit : q) {
    x.push_back(fruit.second);
  }
  sort(x.begin(), x.end());
  for (int i = x.size() - 1; i >= 0; i--) {
    max += x[i] * v[n - x.size() + i];
  }
  reverse(x.begin(), x.end());
  for (int i = 0; i < x.size(); i++) {
    min += x[i] * v[i];
  }
  cout << min << " " << max;
}
