#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  bool allisone = true;
  int zrcounter = n, maxi = 0;
  long long sum = 0, go = 0, count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (a[i] != 1) allisone = false;
    if (a[i] == 0) {
      zrcounter--;
    }
    maxi = max(a[i], maxi);
  }
  if (n == 1) {
    cout << 0;
    return 0;
  }
  long long steps = sum - zrcounter - maxi;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (a[i] > go) {
      go++;
      count++;
    }
  }
  cout << steps + count;
  return 0;
}
