#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int cur;
  priority_queue<int> q;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    if (i == 0)
      cur = temp;
    else
      q.push(temp);
  }
  int ans = 0, temp = q.top();
  while (cur <= temp) {
    cur++, ans++;
    q.pop();
    q.push(temp - 1);
    temp = q.top();
  }
  cout << ans;
  return 0;
}
