#include <bits/stdc++.h>
using namespace std;
int a[1010];
int main() {
  int a[1010];
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < m; i++) {
      scanf("%d", &a[i]);
    }
    sort(a, a + m);
    int ansmin = 0, ansmax = 0;
    int n1 = n, n2 = n;
    for (int i = 0; i < m && n1; i++) {
      ansmin += (n1 >= a[i] ? (a[i] * (a[i] + 1)) / 2
                            : ((a[i] + a[i] - n1 + 1) * n1) / 2);
      n1 >= a[i] ? n1 -= a[i] : n1 = 0;
    }
    for (int i = 0; i < n; i++) {
      ansmax += a[m - 1];
      a[m - 1]--;
      sort(a, a + m);
    }
    printf("%d %d\n", ansmax, ansmin);
  }
  return 0;
}
