#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n);
  long long mx = 0;
  long long tot = 0;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    tot += v[i];
    mx = max(mx, v[i]);
  }
  long long dist = 0;
  sort(v.begin(), v.end());
  long long last = 1e17;
  long long tak = 0;
  for (long long i = n - 1; i >= 0; i--) {
    if (last == 1) {
      tak++;
      continue;
    }
    if (last > v[i]) {
      last = v[i];
      dist++;
      tak++;
    } else {
      last--;
      dist++;
      tak++;
    }
  }
  if (dist == mx) {
    cout << tot - tak;
    return 0;
  }
  tak += (mx - dist);
  cout << tot - tak;
}
