#include <bits/stdc++.h>
using namespace std;
long long int cons;
inline long long int check(long long int a) {
  if (a >= cons) a %= cons;
  return a;
}
inline long long int check2(long long int a) {
  a %= cons;
  if (a < 0) a += cons;
  return a;
}
inline long long int fast_check(long long int a) {
  if (a >= cons) a -= cons;
  return a;
}
long long int GCD(long long int a, long long int b) {
  while (a && b) {
    a = a % b;
    if (a != 0) b = b % a;
  }
  return a + b;
}
long long int exp(long long int a, long long int n) {
  long long int ans = 1;
  a = check(a);
  while (n) {
    if (n & 1) ans = check(ans * a);
    a = check(a * a);
    n = (n >> 1);
  }
  return ans;
}
void print_pair(pair<int, int> p) {
  cout << p.first << " " << p.second << endl;
}
long long int nc2(long long int a) { return (a * (a - 1)) / 2; }
long long int nc3(long long int a) {
  long long int b = a * (a - 1) * (a - 2);
  return b / 6;
}
const int N = 320000;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cons = 1e9 + 7;
  srand(time(NULL));
  long long int n, m;
  cin >> n >> m;
  long long int mm = 0;
  long long int s = 0;
  map<long long int, int> mapp;
  for (int i = 1; i <= n; i++) {
    long long int first;
    cin >> first;
    s += first;
    mapp[first] += 1;
    mm = max(mm, first);
  }
  long long int las = 0, sub = 0;
  for (auto itr : mapp) {
    if (itr.second >= itr.first - las) {
      sub += itr.second;
      las = itr.first;
    } else {
      sub += itr.second;
      las += itr.second;
    }
  }
  sub += mm - las;
  cout << s - sub;
  return 0;
}
