#include <bits/stdc++.h>
using namespace std;
long long int minimum(long long int a[], long long int m, long long int n) {
  long long int ar[m];
  for (long long int i = 0; i < m; i++) ar[i] = a[i];
  long long int j = 0;
  long long int ans = 0;
  while (n > 0) {
    if (ar[j] > 0) {
      ans += ar[j];
      ar[j] -= 1;
      n--;
    } else
      j++;
  }
  return ans;
}
long long int maximum(long long int a[], long long int m, long long int n) {
  long long int ar[m];
  for (long long int i = 0; i < m; i++) ar[i] = a[i];
  long long int ans = 0;
  long long int j = m - 1;
  while (n > 0) {
    ans += ar[j];
    ar[j] -= 1;
    n--;
    long long int maxi = ar[j];
    long long int id = j;
    for (long long int k = m - 1; k >= 0; k--) {
      if (maxi < ar[k]) {
        id = k;
        maxi = ar[k];
      }
    }
    swap(ar[id], ar[j]);
  }
  return ans;
}
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int ar[m];
  for (auto &it : ar) cin >> it;
  ;
  sort(ar, ar + m);
  long long int mini = minimum(ar, m, n);
  long long int maxi = maximum(ar, m, n);
  cout << maxi << " " << mini << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
