#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  long long m;
  cin >> n >> m;
  long long arr[n], sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  sort(arr, arr + n);
  long long hneed = arr[n - 1], extra = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] >= hneed) {
      hneed--;
      continue;
    } else {
      extra += (hneed - arr[i]);
      hneed = arr[i] - 1;
    }
  }
  hneed = max(hneed, 0LL);
  cout << sum - n - extra - hneed;
  return 0;
}
