#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e5 + 5;
long long a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long m;
  cin >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1, greater<long long>());
  long long ans = a[1] - 1, last = a[1] - 1;
  for (int i = 2; i <= n; ++i) {
    if (a[i] < last) {
      ans -= (last - a[i]);
    }
    last = min(last - 1, a[i] - 1);
    ans += a[i] - 1;
  }
  if (last > 0) ans -= last;
  cout << ans;
}
