#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5 + 3);
int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  int arr[m + 1];
  priority_queue<int> pq1;
  priority_queue<int, vector<int>, greater<int> > pq2;
  for (int i = 0; i < m; i++) {
    cin >> arr[i];
    pq1.push(arr[i]);
    pq2.push(arr[i]);
  }
  int min = 0;
  int max = 0;
  for (int i = 0; i < n; i++) {
    int x = pq1.top();
    max += x;
    pq1.pop();
    if (x != 1) pq1.push(x - 1);
    int y = pq2.top();
    min += y;
    pq2.pop();
    if (y != 1) pq2.push(y - 1);
  }
  cout << max << " " << min;
}
