#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  scanf("%lld%lld", &n, &m);
  long long int a[100001];
  for (long long int i = 0; i < n; i++) scanf("%lld", &a[i]);
  long long int sum = 0, now = 0;
  sort(a, a + n);
  for (long long int i = 0; i < n - 1; i++) {
    sum += a[i] - 1;
    if (a[i] > now) now++;
  }
  if (a[n - 1] > now)
    sum += now;
  else
    sum += a[n - 1] - 1;
  printf("%lld\n", sum);
  return 0;
}
