#include <bits/stdc++.h>
using namespace std;
struct data1 {
  int w;
};
bool operator<(data1 x, data1 y) { return x.w > y.w; }
priority_queue<data1> a1;
struct data2 {
  int w;
};
bool operator<(data2 x, data2 y) { return x.w < y.w; }
priority_queue<data2> a2;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x;
    scanf("%d", &x);
    data1 x1;
    x1.w = x;
    data2 x2;
    x2.w = x;
    a1.push(x1);
    a2.push(x2);
  }
  int ans1 = 0;
  int ans2 = 0;
  for (int i = 1; i <= n; i++) {
    data1 x1 = a1.top();
    a1.pop();
    ans1 += x1.w;
    x1.w -= 1;
    if (x1.w > 0) a1.push(x1);
    data2 x2 = a2.top();
    a2.pop();
    ans2 += x2.w;
    x2.w -= 1;
    if (x2.w > 0) a2.push(x2);
  }
  printf("%d %d\n", ans2, ans1);
}
