#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using vi = vector<int>;
using vll = vector<long long int>;
using vd = vector<double>;
using vvi = vector<vi>;
int ctoi(char c) { return c - '0'; }
int slen(string s) { return s.length(); }
int vsize(vi a) { return (int)a.size(); }
int in() {
  int x;
  cin >> x;
  return x;
}
void kmin(long long int n, long long int m) {
  long long int val = n / m;
  n = n - (val * m);
  long long int val1 = (m - n) * (val - 1) * (val) / 2;
  long long int val2 = n * val * (val + 1) / 2;
  long long int val3 = val1 + val2;
  cout << val3 << " ";
}
void kmax(long long int n, long long int m) {
  n = n - (m - 1);
  long long int val = n * (n - 1) / 2;
  cout << val;
  cout << endl;
}
const int M = 1000000;
bool cmp(pair<long long int, long long int> const a,
         pair<long long int, long long int> const b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second < b.second;
}
long long int prime(long long int x) {
  for (long long int i = 2; i * i <= x; i++) {
    if (x % i == 0) return i;
  }
  return x;
}
long long int cd(long long int x) {
  long long int c = 0;
  while (x > 0) {
    x = x / 10;
    c++;
  }
  return c;
}
void solve() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m;
  cin >> n >> m;
  long long int arr[n];
  map<long long int, long long int> mop;
  long long int sum = 0, maxi = 0;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 0; i < n - 1; i++) {
    if (arr[i] > maxi) maxi++;
    sum += arr[i] - 1;
  }
  cout << sum + min(arr[n - 1] - 1, maxi);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t = 1, k = 1;
  while (t--) {
    solve();
  }
  return 0;
}
