#include <bits/stdc++.h>
using namespace std;
template <class x>
vector<typename x::value_type> tovec(const x& a) {
  return vector<typename x::value_type>(a.begin(), a.end());
}
template <class u>
vector<typename iterator_traits<u>::value_type> tovec(u a, u b) {
  return vector<typename iterator_traits<u>::value_type>(a, b);
}
template <typename x>
ostream& operator<<(ostream& cout, const vector<x>& a) {
  cout << "[";
  if (((int)a.size())) cout << a[0];
  for (int i = 0; i++ < ((int)a.size()) - 1;) cout << ", " << a[i];
  return cout << "]";
}
template <typename u, typename v>
ostream& operator<<(ostream& cout, const pair<u, v>& a) {
  return cout << "(" << a.first << ", " << a.second << ")";
}
int n, m;
;
int a[101010];
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  long long s = 0;
  for (int i = -1; ++i < n;) cin >> a[i], s += a[i];
  sort(a, a + n, greater<int>());
  int cur = a[0];
  long long pick = 0;
  for (int i = -1; ++i < n;) {
    if (a[i] >= cur) {
      pick++;
      cur--;
      continue;
    }
    pick += cur - a[i] + 1;
    cur = a[i] - 1;
  }
  if (cur > 0) pick += cur;
  cout << s - pick;
  return 0;
}
