#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0, tmp;
  cin >> n >> m;
  n--;
  priority_queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    q.push(tmp);
  }
  while (m <= q.top()) {
    ans++;
    tmp = q.top();
    q.pop();
    m++;
    q.push(tmp - 1);
  }
  cout << ans;
}
