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