#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, cnt = 0;
  cin >> n >> m;
  long long int sum = 0;
  vector<long int> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum = sum + a[i];
  }
  sort(a.begin(), a.end());
  cnt = n;
  long long int prev = 1;
  for (i = 1; i < n; i++) {
    if (a[i] > prev) {
      prev++;
    }
  }
  cnt = cnt + a[n - 1] - prev;
  cnt = sum - cnt;
  cout << cnt;
  return 0;
}
