#include <bits/stdc++.h>
using namespace std;
void nextPlease() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int sod(int x) { return x == 0 ? 0 : x % 10 + sod(x / 10); }
int solution(int A, int B, int M) {
  if (A % M == 0) return (B / M) - (A / M) + 1;
  return (B / M) - (A / M);
}
int main() {
  nextPlease();
  long long n, m, sumBlocks = 0, constBlocks = 0, lenBefore = 0;
  int arr[100000];
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    sumBlocks += arr[i];
  }
  sort(arr, arr + n);
  long long maxHeight = arr[n - 1];
  for (int i = 0; i < n; ++i) {
    if (arr[i] > lenBefore) {
      lenBefore++;
    }
    constBlocks += 1;
  }
  constBlocks += maxHeight - lenBefore;
  cout << sumBlocks - constBlocks;
}
