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