#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("trapv")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
const int N = 1e5 + 40;
const int MAXK = 12;
const long long int INF = 2000000000000;
const int RANDOM =
    chrono::high_resolution_clock::now().time_since_epoch().count();
long long int expo_pow(long long int x, long long int y) {
  if (y == 0) return 1;
  y = y % ((998244353) - 1);
  x %= (998244353);
  if (y == 0) y = (998244353) - 1;
  long long int res = 1;
  while (y) {
    if (y & 1) res = (res * x) % (998244353);
    x = (x * x) % (998244353);
    y >>= 1;
  }
  return res;
}
long long int modInverse(long long int a, long long int m = (998244353)) {
  return expo_pow(a, m - 2);
}
void solve(int te) {
  int n, m;
  cin >> n >> m;
  int a[n + 2];
  long long int sum = 0;
  for (int i = (1); i < (n + 1); i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a + 1, a + n + 1);
  int cur = 0;
  long long int take = 0;
  for (int i = (1); i < (n + 1); i++) {
    if (i == n) {
      if (a[i] - cur) {
        take += a[i] - cur;
      } else
        take++;
      break;
    }
    if (a[i] <= cur) {
      take++;
    } else {
      cur++;
      take++;
    }
  }
  cout << sum - take << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  int t = 1;
  while (t <= T) {
    solve(t);
    t++;
  }
}
