#include <bits/stdc++.h>
using namespace std;
int gcd(int f, int s) {
  if (s == 0)
    return f;
  else
    return gcd(s, f % s);
}
int const N = 1000006;
long long const M = 1000 * 1000 * 1000 + 7;
long double const ep = .000000000000000001;
int arr[N];
int main() {
  int n, m;
  cin >> n >> m;
  int mx = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
    sum += arr[i];
    mx = max(arr[i], mx);
  }
  sort(arr, arr + n);
  int curr = 1;
  long long ans = n;
  for (int i = 0; i < n; i++) {
    if (curr > mx) curr = mx;
    if (arr[i] >= curr) curr++;
  }
  if (curr > mx) {
    printf("%lld\n", sum - ans);
  } else {
    printf("%lld\n", sum - (mx - (curr - 1)) - ans);
  }
  return 0;
}
