#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, plain, min = 0, max = 0, temp;
  cin >> n >> plain;
  int* mas1 = new int[plain];
  int* mas2 = new int[plain];
  for (int i = 0; i < plain; i++) {
    cin >> mas1[i];
  }
  sort(mas1, &mas1[plain], greater<int>());
  copy(mas1, &mas1[plain], mas2);
  for (int i = 0, pas = n; pas > 0;) {
    if (((mas1[i] >= mas1[i + 1]) || (i == plain - 1)) &&
        ((mas1[i] > mas1[0]) || i == 0)) {
      max += mas1[i];
      mas1[i]--;
      pas--;
    } else if ((mas1[i] >= mas1[i + 1] || i == plain - 1) &&
               mas1[i] == mas1[0]) {
      i = 0;
    } else
      i++;
  }
  for (int i = plain - 1, n1 = n; i >= 0 && n1 > 0 && mas2[0] > 0;) {
    if (mas2[i] <= mas2[i - 1] || i < 0) {
      min += mas2[i];
      mas2[i]--;
      n1--;
      if (mas2[i] == 0) i--;
    } else
      i--;
  }
  cout << max << ' ' << min;
  return 0;
}
