#include <bits/stdc++.h>
using namespace std;
int a[1020];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
  sort(a + 1, a + m + 1);
  int Min = 0, k = n;
  for (int i = 1; i <= m; i++)
    for (int j = 0; j < a[i]; j++) {
      if (k > 0) {
        Min += a[i] - j;
        k--;
      }
    }
  int Max = 0;
  for (int i = 1; i <= n; i++) {
    int j = max_element(a + 1, a + m + 1) - a;
    Max += a[j];
    a[j]--;
  }
  printf("%d %d\n", Max, Min);
  return 0;
}
