#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  long long maxx = INT_MIN;
  long long A[n];
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
    maxx = max(maxx, A[i]);
    sum += A[i];
  }
  long long temp = 1;
  sort(A, A + n);
  for (long long i = 0; i < n; i++) {
    if (A[i] >= temp) temp++;
  }
  temp--;
  cout << (sum - (n + A[n - 1] - temp)) << "\n";
  return 0;
}
