#include <bits/stdc++.h>
using namespace std;
int index(int a[], int n, int x) {
  for (int i = 0; i < n; i++) {
    if (a[i] == x) return i;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  int maxi = 0, mini = 0, count = 0;
  for (int i = 0; i < n; i++) {
    int *te = max_element(a, a + m);
    maxi += *te;
    a[te - a]--;
  }
  int i = 0, j = 0;
  sort(b, b + m);
  while (i < m && j < n) {
    while (b[i] != 0 && j < n) {
      mini += b[i];
      b[i]--;
      j++;
    }
    if (b[i] == 0) i++;
  }
  cout << maxi << " " << mini;
  return 0;
}
