#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  multiset<int> a;
  for (int i = 0; i < m; i++) {
    int ai;
    cin >> ai;
    a.insert(ai);
  }
  int maxans = 0, minans = 0;
  int p = n;
  for (auto it = a.begin(); it != a.end() && p > 0; it++) {
    if (p >= *it) {
      minans += (*it) * (*it + 1) / 2;
      p -= *it;
    } else {
      minans += (*it) * (*it + 1) / 2 - (*it - p) * (*it - p + 1) / 2;
      p = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    auto it = a.end();
    it--;
    int price = *it;
    maxans += price;
    a.erase(it);
    a.insert(price - 1);
  }
  cout << maxans << " " << minans << endl;
  return 0;
}
