#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, ans = 0, s = 0;
  cin >> n >> m;
  long long int a[n];
  a[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    s += a[i];
  }
  sort(a, a + n + 1);
  long long int maxh = a[n];
  long long int col = 0;
  long long int r = 1;
  for (i = 1; i <= n; i++) {
    if (a[i] >= r) {
      ans++;
      r++;
    } else
      col++;
  }
  ans += (a[n] - (r - 1));
  ans += col;
  cout << s - ans << endl;
}
