#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, m, b[maxn];
long long sum;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    sum += b[i];
  }
  if (n == 1) {
    cout << 0;
    return 0;
  }
  sort(b + 1, b + n + 1);
  int h = b[n];
  long long cnt = 0;
  for (int i = n; i > 0; i--) {
    if (h == 1) {
      cnt += i;
      break;
    }
    if (h > b[i - 1]) {
      cnt += h - b[i - 1];
      h = b[i - 1];
    } else {
      ++cnt, --h;
    }
  }
  cout << sum - cnt;
  return 0;
}
