#include <bits/stdc++.h>
using namespace std;
const int N = 2000100;
const long long MOD = 1e9 + 7;
const long long inf = 1e18 + 5;
int _;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (int i = 0; i < (int)n; i += 1) cin >> a[i];
  sort(a, a + n);
  long long max_height = a[n - 1];
  long long start = 1, ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] >= start && start <= max_height) {
      start++;
      ans++;
    } else if (start > max_height) {
      ans++;
    } else
      ans += 1;
  }
  if (start > max_height) {
    cout << accumulate(a, a + n, 0ll) - ans - 1ll << endl;
    return 0;
  }
  ans += max_height - start + 1;
  cout << accumulate(a, a + n, 0ll) - ans << endl;
  return 0;
}
