#include <bits/stdc++.h>
using namespace std;
string sconvert(long long int n) {
  stringstream ss;
  ss << n;
  string str = ss.str();
  return str;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second > b.second);
}
template <typename T>
void imax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void imin(T &x, T y) {
  x = min(x, y);
}
void single() {
  long long int n;
  cin >> n;
  long long int m;
  cin >> m;
  vector<long long int> stacks(n);
  long long int total = 0;
  for (long long int &x : stacks) {
    cin >> x;
    total += x;
  }
  sort((stacks).rbegin(), (stacks).rend());
  long long int answer = 0;
  for (int i = 0; i < n - 1; i++) {
    if (stacks[i + 1] > stacks[i]) {
      stacks[i + 1] = stacks[i];
    }
    if (stacks[i] == stacks[i + 1]) {
      if (stacks[i + 1] != 1) stacks[i + 1]--;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    if (stacks[i] == 1) {
      answer += 1;
    } else {
      answer += (stacks[i] - stacks[i + 1]);
    }
  }
  answer += stacks[n - 1];
  cout << total - answer << '\n';
  return;
}
void multiple() {
  int asdf;
  cin >> asdf;
  while (asdf--) {
    single();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  ;
  single();
}
