#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e5 + 5;
const long long inf = 1e10;
const long long mod = 1e9 + 7;
long long n, m;
long long a[maxN];
long long maxx;
long long sum;
long long res;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) {
    maxx = max(maxx, a[i]);
    sum += a[i];
  }
  sort(a + 1, a + 1 + n);
  for (long long i = n; i >= 1; i--) {
    if (maxx == 0) {
      res += i;
      break;
    }
    if (a[i] < maxx) {
      res += maxx - a[i];
      maxx = a[i];
    }
    res++;
    maxx--;
  }
  if (maxx > 0) {
    res += maxx;
  }
  cout << (sum - res);
  return 0;
}
