#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, m, s = 0, prev = 0;
  cin >> n >> m;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    s += arr[i];
  }
  sort(arr, arr + n);
  for (long long i = 0; i < n; i++) {
    if (arr[i] > prev) prev++;
  }
  cout << s - n - (arr[n - 1] - prev);
  return 0;
}
