#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n, i, j, m, max = 0, min = 0;
  cin >> n >> m;
  k = n;
  vector<int> a(m);
  for (i = 0; i < m; i++) cin >> a[i];
  sort(a.begin(), a.end());
  i = 0;
  while (1) {
    if (a[i] < k) {
      k -= a[i];
      min += (a[i] * (a[i] + 1)) / 2;
      i++;
    } else {
      min += ((a[i] * (a[i] + 1)) / 2) - (((a[i] - k) * (a[i] - k + 1)) / 2);
      break;
    }
  }
  if (m == 1) {
    max += ((a[m - 1] * (a[m - 1] + 1)) / 2) -
           (((a[m - 1] - n) * (a[m - 1] - n + 1)) / 2);
    cout << max << " " << min;
    return 0;
  }
  while (1) {
    if (n > a[m - 1] - a[m - 2] + 1) {
      n -= a[m - 1] - a[m - 2] + 1;
      max +=
          ((a[m - 1] * (a[m - 1] + 1)) / 2) - ((a[m - 2] * (a[m - 2] - 1)) / 2);
      a[m - 1] = a[m - 2] - 1;
      int t = a[m - 1];
      for (j = m - 2; j >= 0 && a[j] > t; j--) a[j + 1] = a[j];
      a[j + 1] = t;
    } else {
      max += ((a[m - 1] * (a[m - 1] + 1)) / 2) -
             (((a[m - 1] - n) * (a[m - 1] - n + 1)) / 2);
      break;
    }
  }
  cout << max << " " << min;
  return 0;
}
