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