#include <bits/stdc++.h>
using namespace std;
const int maxn = 1111;
int ee[maxn * maxn];
int e[maxn];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) scanf("%d", &e[i]);
  sort(e, e + m);
  int min_cost = 0;
  int p = n;
  for (int i = 0; p > 0 && i < m; ++i) {
    if (p <= e[i])
      min_cost += (e[i] * 2 - p + 1) * p / 2, p = -1;
    else
      min_cost += e[i] * (e[i] + 1) / 2, p -= e[i];
  }
  int max_cost = 0;
  p = n;
  while (p--) {
    int max_index = m - 1;
    for (int i = m - 2; i >= 0; --i)
      if (e[i] > e[max_index]) max_index = i;
    max_cost += e[max_index];
    e[max_index]--;
  }
  printf("%d %d", max_cost, min_cost);
}
