#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int& e : a) cin >> e;
  sort(a.begin(), a.end());
  int curHeight = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      if (curHeight < a[i])
        ans += curHeight;
      else
        ans += a[i] - 1;
    } else {
      if (a[i] > curHeight) curHeight++;
      ans += a[i] - 1;
    }
  }
  cout << ans;
  return 0;
}
