#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cerr.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n, 0);
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  a.push_back(0);
  long long y = a[0];
  long long counter = 0;
  for (int i = 0; i < n; i++) {
    counter += max(0ll, a[i] - y);
    long long next = min(y, a[i + 1ll]);
    if (y > next) {
      y = next;
      counter += next;
    } else {
      counter += y - 1ll;
      y = max(1ll, next - 1ll);
    }
  }
  cout << counter << endl;
  return 0;
}
