#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = int(0); i < int(n); i++) cin >> a[i];
  sort(a, a + n);
  int h = 0, cnt = 0, mx = 0;
  long long total = 0;
  for (int i = int(0); i < int(n); i++) {
    mx = max(mx, a[i]);
    total += a[i];
    cnt++;
    if (a[i] > h) h++;
  }
  cnt += mx - h;
  cout << total - cnt << '\n';
  return 0;
}
