#include <bits/stdc++.h>
using namespace std;
int a[1009], b[1009];
int main() {
  int n, m, i, j, ans;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  ans = 0;
  for (i = 1; i <= n; i++) {
    int tmp = -9999999, tmpj;
    for (j = 1; j <= m; j++)
      if (tmp < a[j] && a[j] != 0) {
        tmp = a[j];
        tmpj = j;
      }
    ans += tmp;
    a[tmpj]--;
  }
  cout << ans << " ";
  ans = 0;
  for (i = 1; i <= n; i++) {
    int tmp = 9999999, tmpj;
    for (j = 1; j <= m; j++)
      if (tmp > b[j] && b[j] != 0) {
        tmp = b[j];
        tmpj = j;
      }
    ans += tmp;
    b[tmpj]--;
  }
  cout << ans;
}
