#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n + 1);
  a[0] = 0;
  long long tot = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    tot += a[i];
  }
  sort(a.begin(), a.end());
  long long res = 0;
  long long cur = a[n];
  for (long long i = n; i >= 1; i--) {
    if (cur <= a[i - 1]) {
      res++;
      cur--;
    } else {
      res += cur - a[i - 1];
      cur = a[i - 1];
    }
  }
  cout << tot - res << '\n';
  return 0;
}
