#include <bits/stdc++.h>
using namespace std;
bool compare(int a, int b) { return a > b; }
int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  int b[m];
  for (int i = 0; i < m; i++) {
    b[i] = a[i];
  }
  int j = n;
  int sum = 0, i = 0;
  sort(a, a + m, compare);
  while (j--) {
    sum += a[0];
    a[0]--;
    for (int i = 1; i < m; ++i) {
      if (a[i] <= a[i - 1]) {
        break;
      }
      swap(a[i], a[i - 1]);
    }
  }
  sort(b, b + m);
  j = n;
  i = 0;
  int sum_1 = 0;
  while (j > 0) {
    if (i == m - 1) {
      while (b[i] > 0) {
        if (j == 0) {
          break;
        }
        sum_1 += b[i];
        b[i]--;
        j--;
      }
    }
    if (j == 0) {
      break;
    }
    while (b[i] <= b[i + 1] && b[i] > 0) {
      sum_1 += b[i];
      b[i]--;
      j--;
      if (j == 0) {
        break;
      }
    }
    i++;
  }
  cout << sum << " " << sum_1;
  return 0;
}
