#include <bits/stdc++.h>
using namespace std;
const int N = 200004;
int a[N];
int main() {
  int n, m;
  long long sum = 0;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  sort(a + 1, a + 1 + n, greater<int>());
  a[n + 1] = 0;
  int pre = 0, tp;
  for (int i = 1, j; i <= n; i += j) {
    for (j = 1; i + j <= n; j++)
      if (a[i + j] != a[i]) break;
    tp = a[i] - a[i + j] - pre;
    if (j > tp)
      pre = j - tp;
    else
      pre = 0;
    sum -= max(j, tp);
  }
  printf("%lld\n", sum);
}
