#include <bits/stdc++.h>
int data[1000];
int datacpy[1000];
int max = -1;
int min = 30000;
int n, m;
int findmax() {
  int i, find = 0;
  for (i = 0; i < m; i++) {
    if (find < data[i]) find = data[i];
  }
  return find;
}
int findmax2() {
  int i, find = 0;
  for (i = 0; i < m; i++) {
    if (find < datacpy[i]) find = datacpy[i];
  }
  return find;
}
int findmin() {
  int i = 0, find = findmax2();
  for (i = 0; i < m; i++) {
    if (find > datacpy[i] && datacpy[i] != 0) find = datacpy[i];
  }
  return find;
}
int main() {
  int i, j;
  int sum = 0;
  int cost = 0;
  int costmin = 0;
  int ncpy = 0;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &data[i]);
    datacpy[i] = data[i];
    sum += data[i];
    if (max < data[i]) {
      max = data[i];
    }
    if (min == -1) {
      min = data[0];
    }
    if (min > data[i]) {
      min = data[i];
    }
  }
  if (sum == n) {
    for (i = 0; i < m; i++) cost += data[i] * (data[i] + 1) / 2;
    printf("%d %d", cost, cost);
  } else {
    ncpy = n;
    while (n != 0) {
      for (i = 0; i < m; i++) {
        if (data[i] == max) {
          cost += max;
          data[i] -= 1;
          n = n - 1;
          if (n == 0) break;
        }
      }
      max = findmax();
    }
    printf("%d ", cost);
    n = ncpy;
    while (n != 0) {
      for (i = 0; i < m; i++) {
        if (datacpy[i] == min) {
          while (datacpy[i] > 0) {
            costmin += datacpy[i];
            datacpy[i] -= 1;
            n = n - 1;
            if (n <= 0) break;
          }
          if (n <= 0) break;
        }
      }
      min = findmin();
    }
    printf("%d", costmin);
  }
}
