#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, ans = 0, sum = 0;
  cin >> n >> m;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum = sum + a[i];
  }
  if (n == 1) {
    cout << 0;
    return 0;
  }
  sort(a.begin(), a.end());
  long long max = a[n - 1], y = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] > y) y++;
    ans = ans + 1;
  }
  ans = ans + (max - y);
  cout << sum - ans;
}
