#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  int a[1000];
  int men = 0, may = 0, j = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  sort(a + 0, a + m);
  k = n;
  while (k > 0) {
    int x = min(k, a[j]);
    k -= x;
    men += a[j] * (a[j] + 1) / 2 - (a[j] - x) * (a[j] - x + 1) / 2;
    j++;
  }
  k = n;
  j = m - 1;
  while (k > 0) {
    may += a[m - 1]--;
    k--;
    sort(a + 0, a + m);
  }
  cout << may << endl;
  cout << men;
  return 0;
}
