#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, count = 0, t, t1, sum = 0, l = 0, sum1 = 0, last;
  cin >> n >> m;
  long long int a[m];
  for (long long int i = 0; i < m; i++) cin >> a[i];
  sort(a, a + m);
  long long int j = 0, k = 0;
  while (j != n) {
    t = a[l];
    l++;
    while (t != 0) {
      sum += t;
      t--;
      j++;
      if (j == n) break;
    }
  }
  for (long long int j = 0; j < n; j++) {
    sort(a, a + m);
    sum1 += a[m - 1];
    a[m - 1]--;
  }
  cout << sum1 << " " << sum << endl;
}
