#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
int a[10000], b[10000];
int cmp(const void *a, const void *b) { return *(int *)b - *(int *)a; }
int cmp1(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int n, m, i, j;
  int big, small;
  while (~scanf("%d%d", &n, &m)) {
    big = small = 0;
    for (i = 0; i < m; i++) scanf("%d", &a[i]);
    for (i = 0; i < m; i++) b[i] = a[i];
    for (i = 0; i < n; i++) {
      qsort(b, m, sizeof(b[0]), cmp);
      big += b[0];
      b[0]--;
    }
    for (i = 0; i < m; i++) b[i] = a[i];
    for (i = j = 0; i < n; i++) {
      qsort(b, m, sizeof(b[0]), cmp1);
      for (; b[j] == 0; j++)
        ;
      small += b[j];
      b[j]--;
    }
    printf("%d %d\n", big, small);
  }
  return 0;
}
