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