#include <bits/stdc++.h>
bool hp(int i, int j) { return i > j; }
int personas, aviones, A[10000], B[10000], position = 1, minimo, maximo, permax;
using namespace std;
int main() {
  queue<int> poli;
  scanf("%d %d", &personas, &aviones);
  for (int x = 0; x < aviones; x++) {
    scanf("%d", &A[x]);
  }
  for (int y = 0, m = 0; y < aviones; y++, m++) {
    B[m] = A[y];
  }
  sort(B, B + aviones);
  permax = personas;
  for (int c = 1, d = 0; personas != 0; c++) {
    sort(A, A + aviones);
    if (A[d] >= 1) {
      minimo = minimo + A[d];
      A[d] = A[d] - 1;
      personas--;
    }
    while (A[d] <= 0) {
      d++;
    }
  }
  for (int c = 1, e = aviones; permax != 0; c++) {
    if (B[e] >= 1) {
      maximo = maximo + B[e];
      B[e] = B[e] - 1;
      permax--;
      sort(B, B + aviones);
    }
    while (B[e] <= 0) {
      e--;
    }
  }
  printf("\n%d %d", maximo, minimo);
  return (0);
}
