#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i;
  cin >> n >> m;
  long long a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long ma = a[n - 1];
  long long k = 1, sum = 0, cnt = 0;
  ;
  for (i = 0; i < n; i++) {
    if (k > a[i] && k <= ma) {
    } else
      k++;
    if (a[i] > 1) sum = sum + a[i] - 1;
  }
  if (ma >= k) {
    cnt = cnt + ma - (k - 1);
    cout << sum - cnt << endl;
  } else
    cout << sum << endl;
}
