#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N];
int main() {
  int n, m;
  cin >> n >> m;
  long long sum = 0;
  for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
  sort(a + 1, a + 1 + n);
  int now = a[n];
  long long us = 0;
  for (int i = n; i >= 1; i--) {
    if (a[i] >= now)
      us++, now--;
    else
      us += now - a[i] + 1, now = a[i] - 1;
  }
  if (now >= 1) us += now;
  cout << sum - us;
  return 0;
}
