#include <bits/stdc++.h>
const long long INF = 1e12;
const long long N = 1e5 + 10;
const long long MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = 3.1415926535897932384626433;
using namespace std;
long long n, m;
long long sum = 0;
vector<long long> ar(N);
void input() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  ar.resize(n);
  for (long long &i : ar) {
    cin >> i;
    sum += i;
  }
  sort(ar.rbegin(), ar.rend());
}
int32_t main() {
  input();
  long long take = 0;
  long long y = ar[0];
  for (long long i = 0; i < n - 1; i++) {
    take += max(y - ar[i + 1], 1LL);
    y = max(min(ar[i + 1], y - 1), 1LL);
  }
  cout << sum - take - y << endl;
}
