#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  long long tot = 0, high = 0;
  for (int i = 0; i < n; i++) {
    long long entry;
    cin >> entry;
    pq.push({0, entry});
    tot += entry;
    high = max(high, entry);
  }
  long long undone = 0;
  for (int i = 1; i <= high && pq.size(); i++) {
    while (pq.size() && pq.top().second < i) pq.pop();
    pair<long long, long long> curr = pq.top();
    pq.pop();
    curr.second--;
    if (curr.first == 0) curr.first = 1, undone++;
  }
  cout << tot - high - (n - undone);
  return 0;
}
