#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N];
int main() {
  int n, m;
  long long ans = 0;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ans += a[i];
  }
  if (n == 1) {
    return puts("0"), 0;
  }
  sort(a + 1, a + 1 + n, [](int a, int b) { return a > b; });
  int last = a[1], H = a[1];
  a[++n] = 0;
  for (int i = 1; i <= n; i++) {
    H = min(a[i + 1] + 1, H) - 1;
    ans -= last - (H + 1);
    last = H + 1;
  }
  cout << ans;
}
