#include <bits/stdc++.h>
using namespace std;
inline int ReadInt() {
  int i = 0;
  char c = 0;
  char flag = 1;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    flag = 0;
    c = getchar();
  }
  for (; c >= '0' && c <= '9'; c = getchar()) i = i * 10 + c - '0';
  if (!flag) i = -i;
  return i;
}
inline void WriteInt(int n) {
  if (n < 0) {
    putchar('-');
    WriteInt(-n);
    return;
  }
  if (n < 10)
    putchar(n + '0');
  else {
    WriteInt(n / 10);
    putchar(n % 10 + '0');
  }
}
int n, m;
int top;
long long ans, sum, last;
int A[100100];
int tmp;
int main() {
  scanf("%i%i", &n, &m);
  for (int i = 0; i < n; i++) scanf("%i", &A[i]), sum += A[i];
  sort(A, A + n);
  int top = 0;
  for (int i = 0; i < n; i++)
    if (A[i] > top)
      ans++, top++;
    else
      ans++;
  ans += A[n - 1] - top;
  printf("%I64d", sum - ans);
  putc('\n', stdout);
}
