#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  v.push_back(0);
  sort(v.begin(), v.end(), greater<long long>());
  long long count = 0;
  long long mx = v[0];
  for (long long i = 0; i < n; i++) {
    if (v[i] <= 1) break;
    if (mx == 0) {
      count += v[i] - 1;
    } else {
      long long cur = mx;
      long long nxt = min(mx, v[i + 1]);
      if (nxt == cur) {
        count += v[i] - 1;
        mx--;
      } else {
        mx -= cur - nxt;
        count += v[i] - cur + nxt;
      }
    }
  }
  cout << count << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
}
