#include <bits/stdc++.h>
int Left(int A[], int i, int m) {
  if (2 * i < m)
    return 2 * i;
  else
    return -1;
}
int Right(int A[], int i, int m) {
  if (2 * i + 1 < m)
    return 2 * i + 1;
  else
    return -1;
}
void max_heapify(int A[], int i, int m) {
  int largest;
  int l = Left(A, i, m);
  int r = Right(A, i, m);
  if (l > 0 && A[l] > A[i])
    largest = l;
  else
    largest = i;
  if (r > 0 && A[r] > A[largest]) largest = r;
  if (largest != i) {
    int temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    max_heapify(A, largest, m);
  }
}
void min_heapify(int A[], int i, int m) {
  int largest;
  int l = Left(A, i, m);
  int r = Right(A, i, m);
  if (l > 0 && A[l] < A[i])
    largest = l;
  else
    largest = i;
  if (r > 0 && A[r] < A[largest]) largest = r;
  if (largest != i) {
    int temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    min_heapify(A, largest, m);
  }
}
void build_max_heap(int A[], int m) {
  for (int i = m / 2; i >= 0; i--) max_heapify(A, i, m);
}
void build_min_heap(int A[], int m) {
  for (int i = m / 2; i >= 0; i--) min_heapify(A, i, m);
}
int main() {
  int a[1000], b[1000], m, n;
  while (scanf("%d %d", &n, &m) != EOF) {
    int sum = 0;
    int minimum = 0;
    int maximum = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i];
      sum += a[i];
    }
    build_max_heap(a, m);
    for (int i = 0; i < n; i++) {
      maximum += a[0];
      a[0]--;
      max_heapify(a, 0, m);
    }
    if (sum == n)
      minimum = maximum;
    else {
      build_min_heap(b, m);
      for (int i = 0; i < n; i++) {
        minimum += b[0];
        b[0]--;
        if (b[0] == 0) b[0] = 32767;
        min_heapify(b, 0, m);
      }
    }
    printf("%d %d\n", maximum, minimum);
  }
}
