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