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