#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
using namespace std;
signed main() {
  int t, n, k, m, l, xl, xxl, c = INT_MAX, d = INT_MAX;
  cin >> n >> m;
  int a[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  sort(a, a + m);
  int min = 0;
  int num = a[0];
  k = 0;
  for (int i = 0; i < n; i++) {
    min += num;
    num--;
    if (num == 0) {
      num = a[++k];
    }
  }
  sort(a, a + m, greater<int>());
  int max = 0;
  while (n--) {
    max += a[0];
    a[0]--;
    for (int j = 1; j < m; j++) {
      if (a[j] <= a[j - 1]) break;
      swap(a[j], a[j - 1]);
    }
  }
  cout << max << " " << min << endl;
  return 0;
}
