#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, ara[1005], ara1[1005], i, j, min = 0, max = 0, c = 0;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> ara[i];
    ara1[i] = ara[i];
  }
  sort(ara, ara + m);
  sort(ara1, ara1 + m);
  i = 0;
  while (c < n) {
    min += ara[i];
    ara[i]--;
    if (ara[i] == 0) i++;
    c++;
  }
  c = 0;
  j = m - 1;
  while (c < n) {
    max += ara1[j];
    ara1[j]--;
    sort(ara1, ara1 + m);
    c++;
  }
  cout << max << " " << min << endl;
  return 0;
}
