#include <bits/stdc++.h>
using namespace std;
long long int n;
int dist[30][30];
vector<int> arr[100001];
bool isPrime(long long int n) {
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long int fact(long long int n) {
  if (n <= 1)
    return 1;
  else
    return (n * (fact(n - 1) % 1000000007));
}
long long int comb(long long int n, long long int r) {
  return (fact(n) % 1000000007) /
         ((fact(n - r) % 1000000007) * (fact(r)) % 1000000007);
}
long long int nCr1[1001][1001];
long long int nCr(long long int n, long long int r) {
  if (nCr1[n][r]) return nCr1[n][r];
  if (r == 1) return nCr1[n][r] = n;
  if (n == r) return nCr1[n][r] = 1;
  if (r == 0) return nCr1[n][r] = 1;
  return nCr1[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1)) % 1000000007;
}
bool prime[1000001];
int tuple1[1000001];
int c = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t-- > 0) {
    int n, m1;
    cin >> n >> m1;
    string s;
    map<string, int> m;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
    for (int i = 0; i < m1; i++) {
      cin >> s;
      m[s]++;
    }
    sort(a, a + n);
    sort(b, b + n, greater<int>());
    vector<int> v1, v2;
    for (auto it : m) v1.push_back(it.second), v2.push_back(it.second);
    sort((v1).begin(), (v1).end());
    sort(v2.begin(), v2.end(), greater<int>());
    long long int ans1, ans2;
    ans1 = 0;
    ans2 = 0;
    for (int i = 0; i < m.size(); i++) {
      ans1 += (v2[i] * a[i]);
    }
    for (int i = 0; i < m.size(); i++) {
      ans2 += (v2[i] * b[i]);
    }
    cout << ans1 << " " << ans2 << endl;
  }
  return 0;
}
