#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a[100001], baodung = 0, ans = 0, cnt = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] > baodung) {
      baodung++;
    }
  }
  cnt = n + a[n] - baodung;
  ans = ans - cnt;
  cout << ans;
}
