#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e9;
const long long inf64 = 2e18;
const long long mod = 1000000007;
const long long N = 2e5 + 100;
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (auto &x : a) cin >> x;
  sort((a).begin(), (a).end());
  long long ans = 0, last = 0, total = accumulate((a).begin(), (a).end(), 0ll);
  for (long long i = 0; i < n; i++) {
    if (a[i] > last) last++;
  }
  ans = total - n - (a[n - 1] - last);
  cout << ans;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long tc = 1;
  while (tc--) solve();
}
