#include <bits/stdc++.h>
using namespace std;
int v[1001], v2[1001];
int main() {
  int i, j, s, n, m, max, min, poz;
  cin >> m >> n;
  for (i = 1; i <= n; i++) {
    cin >> v[i];
    v2[i] = v[i];
  }
  s = 0;
  for (i = 1; i <= m; i++) {
    max = 0;
    for (j = 1; j <= n; j++)
      if (v[j] > max) {
        max = v[j];
        poz = j;
      }
    s = s + max;
    v[poz]--;
  }
  cout << s << " ";
  s = 0;
  for (i = 1; i <= m; i++) {
    min = 1001;
    for (j = 1; j <= n; j++)
      if (v2[j] < min && v2[j] >= 1) {
        min = v2[j];
        poz = j;
      }
    s = s + min;
    v2[poz]--;
  }
  cout << s;
  return 0;
}
