#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 1000005;
int SetBit(int n, int x) { return n | (1 << x); }
int ClearBit(int n, int x) { return n & ~(1 << x); }
int ToggleBit(int n, int x) { return n ^ (1 << x); }
bool CheckBit(int n, int x) { return (bool)(n & (1 << x)); }
int arr[105];
char str[35];
int main(void) {
  int n, m, i, a, b, l, p;
  while (scanf("%d %d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) scanf("%d", &arr[i]);
    map<string, int> mp;
    map<string, int>::iterator it;
    for (i = 0; i < m; i++) {
      scanf("%s", str);
      ++mp[str];
    }
    vector<int> v;
    for (it = mp.begin(); it != mp.end(); it++) v.push_back(it->second);
    p = l = v.size();
    a = b = 0;
    sort(arr, arr + n);
    sort(v.begin(), v.end());
    for (i = 0; i < l; i++) a += arr[i] * v[l - 1 - i];
    for (i = n - 1; i >= n - l; i--) b += arr[i] * v[--p];
    printf("%d %d\n", a, b);
    v.clear();
    mp.clear();
  }
  return 0;
}
