#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, ctr = 0, ctr1 = 0, j;
  cin >> n >> m;
  long long int a[m], b[m];
  for (i = 0; i < m; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  long long int p = 0, max = 0, min = 0;
  long long int *ptr;
  for (i = 0; i < n; i++) {
    ptr = max_element(a, a + m);
    max += (*ptr);
    (*ptr)--;
  }
  p = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (b[j] < b[p]) {
        p = j;
      }
    }
    min += b[p];
    b[p] = b[p] - 1;
    if (b[p] < 1) {
      b[p] = 1000007;
    }
  }
  cout << max << " " << min;
}
