#include <bits/stdc++.h>
using namespace std;
long long i, j, k, a[100000], b[100000] = {0}, c[100000] = {0}, x, y, xx, yy, t,
                              p, q, n, ll, rr, r, cap, cap2;
char l[1000][10000], lll[1000], bb[1000], tt;
int main() {
  cin >> x >> y;
  for (i = 0; i < y; i++) {
    cin >> a[i];
  }
  sort(a, a + y);
  t = x;
  p = 0;
  q = 0;
  for (i = 0; i < y; i++) {
    for (j = a[i]; j > 0 && t != 0; j--) {
      p = p + j;
      t--;
    }
  }
  t = x;
  for (i = y - 1; t != 0;) {
    q = q + a[i];
    a[i]--;
    t--;
    if (a[i + 1] > a[i] && a[i - 1] > a[i]) {
      sort(a, a + y);
      i = y - 1;
    } else if (a[i + 1] > a[i])
      i = i + 1;
    else if (a[i - 1] > a[i])
      i = i - 1;
  }
  cout << q << " " << p;
}
