#include <bits/stdc++.h>
using namespace std;
long double PI = 3.14159265358979323846;
void volodya22() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  cout << fixed;
}
long long n, m;
const long long N = 1e6;
long long maxx = 0;
long long s = 0;
long long mas[N];
void input() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> mas[i];
    s += mas[i];
  }
}
long long MOD = 1e5;
void solve() {
  sort(mas, mas + n);
  long long a = 0;
  long long c = mas[n - 1];
  for (long long i = n - 2; i >= 0; i--) {
    c = min(mas[i], c - 1);
    if (c < 1)
      a += mas[i] - 1;
    else
      a += mas[i];
  }
  cout << a;
}
signed main() {
  volodya22();
  input();
  solve();
}
