#include <bits/stdc++.h>
using namespace std;
long long a[105000];
long long sum;
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n, greater<long long>());
  long long highest = a[0];
  long long must = 0;
  long long curr = 0;
  for (int i = 0; i < n; i++) {
    if (highest == 1) {
      must++;
      continue;
    }
    curr = min(a[i], highest);
    if (curr > a[i + 1]) {
      must += curr - a[i + 1];
      highest = a[i + 1];
    } else {
      highest--;
      must++;
    }
  }
  cout << sum - must;
}
