#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 10;
int n, m, a[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a + 1, a + n + 1);
  int X = 0, Y = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > Y) Y++;
    X++;
  }
  X += a[n] - Y;
  cout << sum - X;
  return 0;
}
