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