#include <bits/stdc++.h>
using namespace std;
const int inf = 1e8;
const int N = 1e5 + 5;
const double pi = 3.14159265359;
long long n, m, a[N], sum, mn, ans, cur;
int main() {
  cin >> n >> m;
  mn = 2e9;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    mn = min(mn, a[i]);
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    ans++;
    if (cur < a[i]) cur++;
  }
  ans += a[n] - cur;
  cout << sum - ans;
  return 0;
}
