#include <bits/stdc++.h>
using namespace std;
const int maxn = 1003;
int n, m;
int mat[maxn];
int mat2[maxn];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> mat[i];
  }
  memcpy(mat2, mat, sizeof(mat));
  int a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    int big = 0, ix = 0;
    for (int j = 0; j < m; j++) {
      if (big < mat[j] && mat[j]) {
        big = mat[j];
        ix = j;
      }
    }
    b += big;
    mat[ix]--;
  }
  for (int i = 0; i < n; i++) {
    int less = 1 << 30, ix = 0;
    for (int j = 0; j < m; j++) {
      if (less > mat2[j] && mat2[j]) {
        less = mat2[j];
        ix = j;
      }
    }
    a += less;
    mat2[ix]--;
  }
  cout << b << ' ' << a;
}
