#include <bits/stdc++.h>
using namespace std;
long long n, m, a[100100], maxH, res;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] > maxH) maxH = a[i];
  }
  sort(a + 1, a + n + 1);
  long long Count = 0;
  for (int i = 1; i <= n; i++)
    if (a[i] != 0) {
      res = res + a[i] - 1;
      if ((Count + 1) <= a[i]) Count++;
    }
  if (Count < maxH) res = res - (maxH - Count);
  cout << res << endl;
  return 0;
}
