#include <bits/stdc++.h>
using namespace std;
long long n, m, a[100010], b[100010], c[100010], t, sum, sum2;
int main() {
  scanf("%lld %lld", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum += a[i];
  }
  sort(a + 1, a + n + 1, greater<long long>());
  t = a[1];
  for (int i = 1; i <= n; i++) {
    b[i] = t;
    c[i] = min(a[i + 1] + 1, t);
    t = c[i] - 1;
  }
  for (int i = 1; i <= n; i++) {
    sum2 += (b[i] - c[i] + 1);
  }
  printf("%lld", sum - sum2);
}
