#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  int b[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  int max1 = 0, min = 0, j = m;
  for (int i = 0; i < n; i++) {
    sort(a, a + m);
    max1 += a[m - 1];
    a[m - 1]--;
  }
  j = 0;
  for (int i = 0; i < n; i++) {
    sort(b, b + m);
    if (b[j] == 0) j++;
    min += b[j];
    b[j]--;
  }
  cout << max1 << " " << min;
  return 0;
}
