//方法有点蠢,见笑。
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int min = 0;
int max = 0;
String str = in.nextLine();
String[] s1 = str.split(" ");
int n = Integer.valueOf(s1[0]);
int m = Integer.valueOf(s1[1]);
String str2 = in.nextLine();
String[] s2 = str2.split(" ");
int[] money = new int[n];
for (int i = 0; i < n; i++) {
money[i] = Integer.valueOf(s2[i]);
}
Map<String,Integer> map = new HashMap<>();
for(int i = 0;i<m;i++){
String s = in.nextLine();
if(map.containsKey(s)){
map.put(s, map.get(s)+1);
}else{
map.put(s, 1);
}
}
Arrays.sort(money);
int[] num = new int[map.size()];
int i=0;
for(Map.Entry<String,Integer> s : map.entrySet()){
num[i] = s.getValue();
i++;
}
Arrays.sort(num);
int length = num.length;
for(int j=0;j<length;j++){
min = min+ (num[length-j-1]*money[j]);
max = max+ (num[length-j-1]*money[n-j-1]);
}
System.out.println(min + " " + max);
}
}