#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, sol = 0, ma = 0;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sol += a[i];
    ma = max(ma, a[i]);
  }
  sort(a.begin(), a.end());
  int curr = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > curr) {
      curr++;
    }
  }
  cout << sol - n - (ma - curr) << endl;
  return 0;
}
