#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, t = 0, ans = 0;
  cin >> n >> m;
  long long A[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    ans += A[i];
  }
  if (n == 1)
    cout << 0;
  else {
    sort(A, A + n);
    long long q = 0;
    for (int i = n - 1; i >= 1; i--) {
      if (A[i] != A[i - 1]) {
        if (t > A[i] - A[i - 1] - 1)
          t -= A[i] - A[i - 1] - 1;
        else
          q += A[i] - A[i - 1] - 1 - t;
        t = 0;
      } else
        t++;
    }
    if (A[1] - (n - 2) > 0) {
      if (t > max(min(A[1] - (n - 2) - 2, A[0] - 1), 0LL))
        t -= max(min(A[1] - (n - 2) - 2, A[0] - 1), 0LL);
      else
        q += max(min(A[1] - (n - 2) - 2, A[0] - 1), 0LL) - t;
      t = 0;
    }
    ans -= n + q;
    cout << ans;
  }
  return 0;
}
