#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main() {
  int n, m;
  long long sum = 0, ans = 0, b = 0, last = 0;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  sort(a, a + n + 1);
  for (int i = n; i > 0; i--) {
    b++;
    if (a[i] != a[i - 1]) {
      int d = a[i] - a[i - 1];
      if (d > b) {
        ans += d;
        if (last > d - 1)
          ans -= d - 1, last -= d - 1;
        else
          ans -= last, last = 0;
      } else {
        ans += b;
        last += b - d;
      }
      b = 0;
    }
  }
  printf("%I64d\n", sum - ans);
  return 0;
}
